How to count in nested if statement in matlab? -
i want increment count , display value in message box. i'm using nested if statement. code
if sum( abs( f1(:) - f2(:))) == 0.0 = + 1; elseif sum(abs(f2(:) - f3(:))) == 0.0 = i+ 1; elseif sum(abs(f3(:) - f4(:))) == 0.0 = + 1; else = 1; end h = msgbox('perfect = %d',i);
here f1
,f2
,f3
, , f4
contains difference between 2 images in float. have declared i = 0;
before if statement. still i'm not able see message box in output. tried disp()
function too, showing else
part i.e, i = 1
any suggestions?
thanks in advance!
each mutually exclusive branch of decision tree either i=i+1
or i=1
. no matter 1 runs, if i
0 before, 1 afterwards.
i did not understand want, code written checks several conditions , same thing no matter what, can't right.
edit: try this
if sum( abs( f1(:) - f2(:))) == 0.0 = + 1; end if sum(abs(f2(:) - f3(:))) == 0.0 = i+ 1; end if sum(abs(f3(:) - f4(:))) == 0.0 = + 1; end h = msgbox('perfect = %d',i);
this give count of number of matches, 0 three. conditions checked independently, before second 1 checked if first 1 false.
Comments
Post a Comment