Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hi,
I need help with using if statements with matrices. I don't think masking will help here since the code should be able to determine if the friction angle is 0 or not.
If anyone could help find a solution, I'd really appreciate it. This is my 3rd week of using mathcad - currently trying to transfer all our company's geotechnical excel worksheets to mathcad.
Solved! Go to Solution.
One would expect that if you vectorize the expression you created it should work as expected. But unfortunately Prime does not allow to vectorize a comparison operator like ">".
One possible way out is to write a program which cycles through all the vector elements using a for-loop and creates the desired vector of values:
Another way is to write a utility program which does the comparison and then call this program vectorized (which is something which Prime would allow ;-):
Of course you could also use the if-function instead of the if-statement. It may be less clear but is more compact and also works in Express:
The screenshot you try to duplicate does not state what should happen if the angle is negative!
I followed your attempt which treats negative values like zeros.
One would expect that if you vectorize the expression you created it should work as expected. But unfortunately Prime does not allow to vectorize a comparison operator like ">".
One possible way out is to write a program which cycles through all the vector elements using a for-loop and creates the desired vector of values:
Another way is to write a utility program which does the comparison and then call this program vectorized (which is something which Prime would allow ;-):
Of course you could also use the if-function instead of the if-statement. It may be less clear but is more compact and also works in Express:
The screenshot you try to duplicate does not state what should happen if the angle is negative!
I followed your attempt which treats negative values like zeros.
One could also make the comparison function a local function ...
I think Prime will allow vectorization of the comparison operators; it's "if" that it doesn't like (for the baffling reason that "if" is a ""pseudo function").
Stuart
I think Prime will allow vectorization of the comparison operators; it's "if" that it doesn't like (for the baffling reason that "if" is a ""pseudo function").
Yes, I guess you are right. Vectorization is even done implicitly in that case
Thank you so much! Went with the 1st option but the other options you provided will definitely help me a lot in the very near future.