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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

How to check each member of a vector and IF statement

EN_9902818
12-Amethyst

How to check each member of a vector and IF statement

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,

ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:EN_9902818)

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

View solution in original post

11 REPLIES 11
Werner_E
25-Diamond I
(To:EN_9902818)

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

Werner_E_0-1629385697413.png

 

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,

Werner_E
25-Diamond I
(To:EN_9902818)

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.

 

LucMeekes
23-Emerald III
(To:EN_9902818)

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

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

 

 

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,

LucMeekes
23-Emerald III
(To:EN_9902818)

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

Thanks Luk,

 

That  works great! attached the worksheet

 

StuartBruff
23-Emerald III
(To:EN_9902818)


@EN_9902818 wrote:

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,


Do you mean something like this?

 

2020 04 04 A.png

 

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

Maybe it should be

Werner_E_1-1629397822339.png

 

Maybe this variant is preferred

Werner_E_2-1629398092082.png

 

Lets wait for the OP to answer and clarify

 

 

 

StuartBruff
23-Emerald III
(To:Werner_E)


@Werner_E wrote:

Maybe it should be

Werner_E_1-1629397822339.png

 

Maybe this variant is preferred

Werner_E_2-1629398092082.png

 

Lets wait for the OP to answer and clarify


Yes, the parentheses do clarify where the comparison lies.

 


Lets wait for the OP to answer and clarify


Indeed.  I'm not sure exactly what is wanted.

 

Stuart

Announcements

Top Tags