Skip to main content
1-Visitor
August 19, 2021
Solved

How to check each member of a vector and IF statement

  • August 19, 2021
  • 2 replies
  • 3857 views

Hi guys,

 

I'm pretty new in mathcad and I really need your help.

I have a vector and I want to check each member of it, if it is negative or positive. If it is negative, I want to compare it with a value but if it is positive I want the program to stop.

Please see attached

 

Cheers,

Best answer by LucMeekes

If I understand correctly:

LucMeekes_2-1629393507119.png

and gives:

LucMeekes_1-1629393266852.png

or:

LucMeekes_3-1629393537571.png

Gives:

LucMeekes_4-1629393554037.png

And with a different check value (after all: small and large are relative concepts):

LucMeekes_5-1629393566857.png

 

Success!
Luc

2 replies

25-Diamond I
August 19, 2021

I can't read Prime7 files. Are you looking for something like this:

Werner_E_0-1629385697413.png

 

1-Visitor
August 19, 2021

Hi,

 

yes, something like this but I don't want the results in a vector. Just a small program that if a condition is satisfied the program to return a value a otherwise to return a value b.

Can this be done?

 

cheers,

25-Diamond I
August 19, 2021

You wrote that you want ALL positive values to be compared with a check value. So some may be greater than the check, some may not be greater. So what should the return value of that function be in this case?

What return of the function do you expect with the example vector A and the check value 20 in your sheet? I guess "no uplift" as no value is grater than 20.

Maybe it helps if you write down a couple of vectors like the one in your sheet and tell us the result you'd like to see.

 

23-Emerald IV
August 19, 2021

There are more solutions to your problem.

I guess the description doesn't match your attempt to program. I followed the program attempt.

 

 

Success!
Luc

1-Visitor
August 19, 2021

Hi Luc,

 

The second solution actually works but the issue is that I don't want this to return a vector. I just want to check all the values and either write "OK" or write "Uplift doesn't exist''. Can this be done?

 

EN_9902818_1-1629389467265.png

 

 

1-Visitor
August 19, 2021

So actually, to choose only the values of the vector that are positive and check these. If there are no such values to return no uplift exists, not sure I have confused you more

thanks,