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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Help needed in building if statement

ChrisRae
1-Visitor

Help needed in building if statement

I'm a complete newbie to Mathcad, so please excuse my rather basic question. I'd like to use an if statment to evaluate the values in a vector.
5b36ae19f9
I'm expecting the output, (1,0), but the if statement won't accept a non-scalar value next to the operator (input). I can do the operation on each value in the input vector separately, like this...
5b36ae19f9
and
5b36ae19f9
but the if statement can't be vectorised with my attempts. Any help would be appreciated...
4 REPLIES 4
RichardJ
19-Tanzanite
(To:ChrisRae)

You need to use a for loop in the program to loop through the elements of the vector. However, there is a much easier way. Just type test:input<25 test will then be the desired vector. Richard

Thanks for the quick reply, the example I gave was rather oversimplified, so I'm looking at for loops now... So I've got...
0812ea038d
but this appears to only yield the last of the loop's results, so output = 0 and not (1,0) how do I put each of the loop results into the appropriate location in the output vector? Thanks again for helping me with what's probably a stupidly simple question.
RichardJ
19-Tanzanite
(To:ChrisRae)

Explaining how to do things with pseudo code might work this time, but sooner or later (probably sooner) it's just going to lead to more confusion. This forum is something of a backwater in the Mathcad community. This is the main forum: http://collab.mathsoft.com/~mathcad2000 Go to that forum and post your question and a worksheet showing what you have done. You could post a worksheet here, but there is a lot more activity over on the main forum. Another problem with this forum is that they have set ridiculously low upload limits for files, so if we continue this discussion here you might run into that problem too. Richard

Will do, thanks.
Announcements

Top Tags