cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

SOLVED
Newbie

## Help to correct the mathematical expression

Any one can help me to correct the error in may mathermatical expression. The second condition are not also readed by this expression same with the example I attached -2.33<-1

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Help to correct the mathematical expression

As Stuart already stated - you have to use vectorization. You cannot compare a vector to a scalar (and what Mathcad's symbolics does is a bug).

Unfortunately the if expression can not be vectorized directly, so the best approach in my opinion is to cretae a function to do the calculations and call this function vectorized. The additional benefit is that you can use the very same function for both giframe and goframe. You may wish to change my function- and argument-names.

You used the symbolic evaluation because it (sometimes) yields a result. But I would call that a bug as the results may be wrong. It seems that the symbolics always assumes that the first condition is true, no matter what the value is.

6 REPLIES 6

## Re: Help to correct the mathematical expression

Place a Vectorize operator over the entire expression on the right hand side. The "if" operators expect to get a scalar result, whereas your expressions use vectors. The vectorize operator makes Mathcad operate on each element, hence satisfying the needs of the if statements.

It's generally better to post a worksheet, as well as an image, because it can be quite difficult to see what's going on in many cases, eg an index looks the same as a subscripted name, making it near impossible to spot a typo. Furthermore, the source of the error might lie somewhere other than the place the error shows up.

Stuart

Dear Stuart

## Re: Help to correct the mathematical expression

Unfortunately, I don't have Prime, so can't read your file. But if you select the whole of the expression on the right hand side and go to the matrix ribbon tab, you should be able to find the vectorize operator .. It might even be available from the main ribbon in the operator section.

Stuart

## Re: Help to correct the mathematical expression

As Stuart already stated - you have to use vectorization. You cannot compare a vector to a scalar (and what Mathcad's symbolics does is a bug).

Unfortunately the if expression can not be vectorized directly, so the best approach in my opinion is to cretae a function to do the calculations and call this function vectorized. The additional benefit is that you can use the very same function for both giframe and goframe. You may wish to change my function- and argument-names.

You used the symbolic evaluation because it (sometimes) yields a result. But I would call that a bug as the results may be wrong. It seems that the symbolics always assumes that the first condition is true, no matter what the value is.

## Re: Help to correct the mathematical expression

Doh! I'd forgotten about not being able to vectorize an if statement!

Stuart

## Re: Help to correct the mathematical expression

Thank you ! Problem solved.

Announcements