Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
horizontal Transition code error index out of bounds anyone help!!!
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
horizontal transition:
horizontal scanning thro block and finds no of times pixel value change state from 0 to 1 or 1 to 0
my coding :
[r c]=size(g);
for i=1:r-1
for j=1:c-1;
if(j==c)
break;
elseif g(i,j)==0 && g(i,j+1)==1
c=c+1;
end
end
end
disp(c);
and error is
Attempted to access g(213,1118); index out of bounds because size(g)=[1537,1117].
Error in ==> ht at 8
elseif g(i,j)==0 && g(i,j+1)==1
can anyone help to solve dis pls?
0 comentarios
Respuestas (2)
Walter Roberson
el 24 de Mayo de 2012
You could encounter that error if g has more than 2 dimensions.
By definition, if you use two output arguments, then
[r c] = size(g)
would be the same as
t = size(g);
r = t(1);
c = prod(t(2:end))
If for example, you had a 10 x 10 x 3 g matrix, then [r c] = size(g) would be r=10 and c=10*3
Of course other parts of your code are likely to have logical problems if g has more than 2 dimensions, but this size() problem is the way that you end up with the second dimension being out of range.
2 comentarios
Walter Roberson
el 24 de Mayo de 2012
Please show us the values of r and c as known to your program (that is, put in a breakpoint and see what the _program_ thinks they are.)
La pregunta está cerrada.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!