if statement logical error
显示 更早的评论
Hello, I am working with image processing toolbox and I keep getting the wrong results the main idea is that I calculate some features form any image and store these values in a row vector (s), and a variable (e) then I compare the list of results with range values in the if statement the problem is it keeps getting the else part even if the if part is right??
this is the if statement part:
if(s(1)<=0.1649 && s(1)>=0.1062)...
&&(s(2)<= 0.9737&& s(2)>=0.9620)...
&&(s(3)<=0.3081 && s(3)>=0.2421)...
&& (s(4)<=0.9501 && s(4)>=0.9278) && (e<=5.4846 && e>=5.1281)
results='Positive Results';
else
results='Negative Results';
end
assume s and e were input as follows
s=[0.1630 0.9710 0.2421 0.9286];
e=5.4846;
please help,thank u in advance..
1 个评论
Junaid
2011-12-1
Dear friend. I don't see any logical error. Output is Result = 'Positive Results'. This is what it should be as all conditions are true.
采纳的回答
更多回答(1 个)
Junaid
2011-12-1
Dear when I execute your code, i get the if part not else part. I also checked your all conditions and all conditions are true.
If you are confuse in any part you can check all condition one bye one like this.
s(4)<=0.9501 && s(4)>=0.9278
it should output 1. then you can debug it yourself. So far your all conditions are true and you get Result = ' Positive Results'.
类别
在 帮助中心 和 File Exchange 中查找有关 Common Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!