jeudi 14 mai 2015

How to count in nested if statement in matlab?

I want to increment the count and display the value in a message box. I'm using a nested if statement. This is my code

if sum( abs( f1(:) - f2(:))) == 0.0
       i = i + 1;
elseif sum(abs(f2(:) - f3(:))) == 0.0
       i = i+ 1;
elseif sum(abs(f3(:) - f4(:))) == 0.0
       i = i + 1;
else 
       i = 1;   
end

h = msgbox('Perfect  = %d',i);

Here f1,f2,f3, and f4 contains the difference between two images in float. I have declared i = 0; before if statement. Still I'm not able to see the message box in the output. I tried with disp() function too, but its showing only the else part i.e, i = 1

Any suggestions?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire