- 1 < C, when A is smaller than B, or
- 0 < C, when A is not smaller then B
Ignoring If statements error
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi I am having trouble with my selection of if statements to sort out a minvalue grab from my array. In previous code the min function incorrectly grabed the wrong value that wasnt even close to being the minimum value in the array. To try and correct this mistake I made a series of If Statements that account for the changing poitions of the value real value trying to be detected through ranges. Xep is the value that is stable and doesnt have a problem with finding its measured location. Xbp is the error problem. The two variables should be no more than pixels away from each other and when they are this error occurs and I try to fix it with these If Statements:
if(20 <= (Xep - Xbp))
if(450<=Xep<=500)
j=450;
while DC1(1,j) ~= min(DC1(:,450:500)),DC1(1,j);
Xbp = j;
j=j+1;
end
end
if(350<=Xep<=449)
j=350;
while DC1(1,j) ~= min(DC1(:,350:450)),DC1(1,j);
Xbp = j;
j=j+1;
end
end
if(250<=Xep<=349)
j=250;
while DC1(1,j) ~= min(DC1(:,250:349)),DC1(1,j);
Xbp = j;
j=j+1;
end
end
if(150<=Xep<=249)
j=150;
while DC1(1,j) ~= min(DC1(:,150:249)),DC1(1,j);
Xbp = j;
j=j+1;
end
end
if(1<=Xep<=149)
j=1;
while DC1(1,j) ~= min(DC1(:,1:149)),DC1(1,j);
Xbp = j;
j=j+1;
end
end
end
Xbp: 45 Xep: 417
I am unsure why this error is occuring as my If Statements seem to make sense to be. But when the code runs into the error with values like the two above, nothing happens and the code just skips over the If Statements like their not there.
Can someone please help me with this?
0 Kommentare
Akzeptierte Antwort
Jos (10584)
am 26 Mai 2014
the expression
A < B < C
will be interpreted in matlab as
This will be true or false depending on the value of C.
You (most likely) want
A < B AND B < C
which is notated in matlab as
A < B && B < C
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!