Why is my if statement making the values of a previous array disappear?
Mostra commenti meno recenti
My code basically looks like:
for x = 1:xmax
for y = 1:ymax
for l = 1:xmax
for m = 1:ymax
d(x,y,l,m) = (x-l)^2 + (y-m)^2
if f(x,y,1) ~=f(x,y,5)
%lots of new defined values
else
break
end
end
end
end
end
There is no problem when I remove the if statement, I get the correct array for d. But when the if statement is there the output of d is all zeros. Does anyone know why d is not calculated when I have the conditional in there since it's outside of the if?
Risposte (2)
Image Analyst
il 17 Giu 2014
0 voti
How would the f array ever change? And, have you tried stepping through the code with the debugger? That's what I do, and everyone else would do. Try this: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/
Categorie
Scopri di più su Entering Commands in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!