From: ravi on
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
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
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
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
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