Matlab value assignment acting weird
Mostrar comentarios más antiguos
Hi!
I have the following code (as a part of a bigger program, mainly for image processing):
P_hatso3_x = P_hatso2_x;
w6 = 1;
disp('axax')
y_alap6 = P_hatso2_y
disp('dasd')
while (w6 == 1)
if (pixel_labels(y_alap6,P_hatso3_x) == szegm_lab)
y_alap6 = y_alap6 - 1;
else
w6=0;
P_hatso3_y = y_alap6;
end
end
Now when I run it, it returns with the following command window:
axax
y_alap6 =
72
dasd
Subscript indices must either be real positive integers or logicals.
Error in kmeans_proba_advanced (line 293)
if (pixel_labels(y_alap6,P_hatso3_x) == szegm_lab
so it returns with an error, because the
pixel_labels
binary array can not be indexed with the variable called
y_alap6
because it has a value of 0 . However, as we see on the command window, the value 72 had been assigned to it before (between 'axax' and 'dasd' strings), but it somehow magically disappeared/changed/got unassigned 3 lines later. I am really confused, as this only comes up for some of the pictures I am trying to process with this program, I just can't find out why this could be. Can someone please help me?
Respuesta aceptada
Más respuestas (1)
the cyclist
el 6 de Mayo de 2017
0 votos
You don't mention the value of P_hatso3_x, which is also used as an index. Are you also confident that it is a non-zero integer?
Can you set a breakpoint at that actual line of code, and see that values at that moment?
1 comentario
Categorías
Más información sobre Convert Image Type en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!