How to loop over the columns?
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Bruno
      
 el 28 de Oct. de 2016
  
    
    
    
    
    Comentada: Bruno
      
 el 29 de Oct. de 2016
            I have a matrix 101x19, I want to flip each column upside down to turn peaks in valley:
How I can do a loop?
 for i=1:length(data);   
 Flipdata(i,:) = 1.001*max(data,i-1)-(data,i);  
 end
0 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 28 de Oct. de 2016
         for i=1:size(data,2)
   Flipdata(:,i) = 1.001 * max(data(:,i)) - data(:,i); 
 end
or, with no loop,
Flipdata = repmat(1.001 * max(data), size(data,1), 1) - data;
and if you have R2016b or later
Flipdata = 1.001 * max(data) - data;
Más respuestas (0)
Ver también
Categorías
				Más información sobre Loops and Conditional Statements 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!

