Error: Attempted to access din(289,1); index out of bounds because size(din)=[288,543].
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    vetri veeran
 el 27 de Oct. de 2014
  
    
    
    
    
    Comentada: Jan
      
      
 el 27 de Oct. de 2014
            My code is,
din=imread('pic1.jpg'); figure(1); imshow(din); din=im2double(din); [m,n]=size(din);
for i=1:m for j=1:n if(din(i,j)==1) din(i,j)=1000; else din(i,j)=0; end end end
din(:,1) = 0; % Make first column 0. din(:,end) = 0; % Make last column 0. din(1,:) = 0; % Make first row 0. din(end,:) = 0; % Make last row 0. figure(2); imshow(din);
for j=2:1:n+1
    for i=2:1:m+1
        din(i,j)=min([din(i,j);1+din(i-1,j);
            1.41+din(i-1,j-1);1+din(i,j-1);1.41+din(i+1,j-1)]);
    end    
end
Error: Attempted to access din(289,1); index out of bounds because size(din)=[288,543].
Error in distance (line 46) din(i,j)=min([din(i,j);1+din(i-1,j);
Thanks in advance.
1 comentario
  Jan
      
      
 el 27 de Oct. de 2014
				Please apply a proper code formatting. It is easy and discussed 10 times each day.
Respuesta aceptada
  Zoltán Csáti
      
 el 27 de Oct. de 2014
        The error occurs first when i=m+1 (ie. 289) and j=2 since you refer to din(289,1). In this case the debugger is useful.
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


