From: ravi on 8 Aug 2010 19:09 Folks, I want to test the following: 566> 100 243> 150 753>200 566<210 243<120 753<400 And thus let Matlab print : 1 But I keep getting the error "??? Operands to the || and && operators must be convertible to logical scalar values". I'm asking for some help. my code is: %%%%%%%%%%%%%%%%%%%%%% zz = [566 243 753] hh= [ 100 150 200 ; 210 120 400] if (zz>hh(1,:)) && (zz<hh(2,:)) 1 else 0 end %%%%%%%%%%%%%%%%%%%%%%%
From: ImageAnalyst on 8 Aug 2010 20:18 Try this: zz = [566 243 753] hh= [ 100 150 200 ; 210 120 400] if all(zz>hh(1,:)) && all(zz<hh(2,:)) fprintf(1,'The answer is 1\n'); else fprintf(1, 'The answer is 0\n'); end Actually you have 6 results. I just said to report 1 if all 3 of the > tests were true and all 3 of the < tests were true.
From: ravi on 8 Aug 2010 21:28 Why doesn't it return "The answer is 1" ,since all tests are true, instead when i execute i get "The answer is 0". Also ,is it possible to test each individually in the case I may have a situation as follows? : 566> 100 243< 300 753>200 thanks ravi
From: ImageAnalyst on 8 Aug 2010 21:37 All tests are NOT true. These tests you said to make are false: 566<210 243<120 753<400 Of course it if possible to test number pairs one at a time. Do it that way if you want.
From: ravi on 8 Aug 2010 21:47 Is there a keyword similar to "all" that i can use for testing individual numbers? If not ,please give me a hint on how I can do it. thanks for the help ravi
|
Next
|
Last
Pages: 1 2 Prev: plotting a 3D data in plane by color Next: non linear simultaneous eqns |