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!

Too Many OR Statements - need loop

Status
Not open for further replies.

subengr

Structural
Joined
May 10, 2010
Messages
9
Location
US
If I have a unity check matrix:


.67
.90
.55
UC = .54
.90
1.03
.68

I want it to do a check of all the numbers in the matrix and if a number is above one I want it to say "NG", otherwise write "OK". However I dont want to do a bunch of OR statements because the real matrix is a lot bigger (if UC[1]>1 OR UC[2]>1,...,etc).

How can I create a loop that does the same thing? Right now I doing if UC[n]>1 then "NG" but it doesnt seem to want to run the way I wrote it.

Thanks
 
Why can't you use the MAX function?

TTFN

FAQ731-376
 
You are right...but it still bugs me that I cant get that loop to work. Thanks
 
There are still brute force and ignorance approaches:

IF(SUM(IF(a[n >= 1,1,0), "NG" , "OK"))) is one approach, where SUM is the summation operator. You essentially do a SUMIF the value is greater than or equal to 1, and if the sum is greater than 0, then the second if outputs "NG, otherwise "OK" There is a bit of a cheat, since you should do IF(SUM(blah)>0

TTFN

FAQ731-376
 
n:=0..6
Under1[n:=if(UC[n<1,"OK","NG")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top