Skip to main content
1-Visitor
May 11, 2016
Solved

If statement with vector in it?

  • May 11, 2016
  • 1 reply
  • 11640 views

What is the proper way (in Prime 3.1) to create an if statement that compares the values of a vector to a single value? Please see the attached photo for a better description.

Best answer by LucMeekes

Like this?

Success!
Luc

1 reply

1-Visitor
May 11, 2016

It depends on what you want as a result:

If you want a vector of 1's and 0's that's the same size as your comparison vector, use the "vectorization" operator.

If you want a single 1 or 0 (e.g. if all values are less than 0.2), use the comparison max(Vua/Vn)<0.2

dsochor1-VisitorAuthor
1-Visitor
May 11, 2016

Thank you Mark, I'm looking for the first result. I tried multiple arrangements of the "vectorize" operator and each resulted in an error. What is the correct way to use the vectorize operator in this situation?

1-Visitor
May 11, 2016

Hmm.. it appears the vectorization operator does not seem to work with "if" statements.  We could write a program.  However, if you true and false results are simply 1 and 0, you don't even need the "if" statement:

Mathcad already stores "true" as 1 and "false" as 0.