Adding entry to a matrix loop
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Jacob Hollebon
 el 12 de En. de 2017
  
    
    
    
    
    Comentada: John Chilleri
      
 el 13 de En. de 2017
            I have a matix, A, of 100x200 zeros. I will be taking data from an oscilloscope that will continually be written to a matrix, B, 1X1. I want to write a loop that inputs B into the spot 1,1 of A. Then after the oscilloscope has taken new data and rewritten B, input it into spot 1,2. When the first line is complete I want the data to go into 2,1 and so on till A is full up. How might I write this loop?
1 comentario
  John D'Errico
      
      
 el 12 de En. de 2017
				
      Editada: John D'Errico
      
      
 el 12 de En. de 2017
  
			Why pray tell, do you want to write data into a matrix along those diagonals? Where does the 4th element go?
Respuesta aceptada
  John Chilleri
      
 el 12 de En. de 2017
        
      Editada: John Chilleri
      
 el 12 de En. de 2017
  
      Hello,
You can fill in your matrix by rows with this:
for i = 1:100
   for j = 1:200
      % Acquire your B
      A(i,j) = B;
   end
end
Hope this helps!
3 comentarios
  John Chilleri
      
 el 13 de En. de 2017
				Your loop goes from i=1:100 and j=1:200 correct? Not 0:100 and 0:200? This error occurs when you try to access A(0,0) which does not exist.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!