Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statements for matrices 1

Status
Not open for further replies.

juhop

Mechanical
Aug 6, 2008
7
I am quite new to Mathcad, and am wondering if there's a simple way to run 1D matrices through if statements. Currently the if statement just complains about the variable not being a scalar, and doesn't therefore process the variable.

Thank you.
 
Replies continue below

Recommended for you

You can either vectorize it or index it.

TTFN

FAQ731-376
 
Unfortunately, the vectorize operator doesn't apply to if statements. The normal way to use if statements in conjunction with arrays is to use a program for-loop or a range variable.

eg: i:=0..3
ans[i:=if(v[i>0,3,-3)

or

for i e 0..3
ans[i<- 3 if v[i>0
ans[i<- -3 otherwise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor