for if matrix
    1 visualización (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Amit
 el 3 de Feb. de 2012
  
for i=1:n-1
    for j=1:n-1
        for r=1:332
            if i + r  > 333
              data(i+r,:)=0;
                    *else if i-r = < 0
                            data(i-r,:)=0;*
                            else if j+r > 333
                                    data(:,j+r)=0;
                                     else if j-r = < 0
                                            data(:,j-r)=0;
                                         end
                                end
                          end
            end
          end
      end
  end
Please tell me how I can correct the error at i-r = < 0
Respuesta aceptada
  Walter Roberson
      
      
 el 4 de Feb. de 2012
        Change the '= <' to '<=' (without the apostrophes.)
9 comentarios
  Walter Roberson
      
      
 el 4 de Feb. de 2012
				Your line s=s+data(i+r,j)+data(i-r,j) is outside of any of your "if" tests, so it is going to always be executed. It will cause a problem if i-r is 0 or negative. 
Más respuestas (1)
  Jan
      
      
 el 4 de Feb. de 2012
        Do you really have a space between the = and the < ? If so, remove it.
Please add the error message. Otherwise we have to guess, what your problem might be.
Ver también
Categorías
				Más información sobre Logical en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


