Skip to main content
1-Visitor
December 5, 2012
Question

how to get a value expected from an Array in a given condition??

  • December 5, 2012
  • 2 replies
  • 2230 views

Hi everyone,

I need to know how to get a value expected from an Array in a given condition??

for example, there is two arrays, a and Step.

a contains two values: 0.96 and 1

Step contains two string values: "O" stands for operation condition, and "S" for system test condition.

Now, i wanna a value is equal to 0.96 during the "operation" condition, and equal to 1 for test condition.

I made a programming solution, giving If function to describe my ideas, but it doesn't work. When i re-define Step:="S", then a shows strangely "NA" instead of the value 1 what i expected.

Anyone can help? thanks in advance

2 replies

24-Ruby IV
December 5, 2012

au.png

ychen1-VisitorAuthor
1-Visitor
December 5, 2012

i try to get the value au in test condition, taping Step:="S" at somewhere, but i still get "0.96".

why??

it seems "au" depends strongly on the first assignment of Step:=, even a more detailed assignment is given in program, but it can't read it !!!

23-Emerald I
December 5, 2012

In your program, Mathcad evaluates "au" as a variable wen it's encountered. In test0, the value of Step was not set, so it defaulted to 0 (the number.) So the evaluation of au came back "NA". The fact that you defined Step below that did not change the value of au.

The solution is to make au a function of Step, see the attached file. au(Step);=

Now each time we encounter au(), we evaluate it for whatever is in the parenthesis.

25-Diamond I
December 5, 2012

It seems to me that you want to define au before you decide which value Step should get. If thats true you will have to use a function.

Probably a listbox component is an option. See attached worksheet for two examples

WE

25-Diamond I
December 5, 2012

Sorry, I was too late. I haven't seen your second question and Freds answer while typing my post.

ychen1-VisitorAuthor
1-Visitor
December 6, 2012

Hi guys,

Thanks for all your help.

PS: Werner, it's cool your solution, i've never used it before (actually, i'm new user since last week, haha), thanks for sharing..