Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Problem filtering negative values of a matrix using loop statements

Status
Not open for further replies.

erloroloco

Mechanical
Joined
Jan 16, 2007
Messages
2
Location
GB
Having a matrix defined by one column with 4000 integer values in rows, I would like to convert the negative ones into 0.

e.g.

v=[0;-1;-2;4;..]

vconvert=[0;0;0;4]

Therefore I tried to use the example described in the Mathcad13 tutorial, which skips over the nonpositive numbers with a "continue statement".I don't get a solution. Other procedures like "if statements" are also helpless for this "rookie" beginner.

I would be really delighted if someone could help me with an elegant solution.

Thanks a lot.
 
If you want to do it without programming, one way is:

(v + abs(v))/2

2 notes: One, make sure to vectorize the equation (matrix toolbar). Two, make sure to use the absolute value from the calculator toolbar, not the matrix toolbar (which is actually the determinate).

Peter
 
Already answered in Mathcad Collab. Problem was trying to modify a range variable.

TTFN



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top