what does "put a vector of ones in the 2nd row and a vector of ones in the 5th column" mean when I have a 10x10 matrix of zeros?
    4 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Tai Lopez
 am 8 Okt. 2018
  
    
    
    
    
    Kommentiert: madhan ravi
      
      
 am 9 Okt. 2018
            Hello,
I've been asked to put a vector of ones in the 2nd row and a vector of ones on the 5th column. I have a 10x10 matrix of zeros (I used this command: zeros(10,10)). Does anyone know what this means and how do I do it?
Thanks
0 Kommentare
Akzeptierte Antwort
  madhan ravi
      
      
 am 8 Okt. 2018
        
      Bearbeitet: madhan ravi
      
      
 am 8 Okt. 2018
  
      >> A=zeros(10,10)
A(2,:)=1
A(:,5)=1
A =
    Columns 1 through 8
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
    Columns 9 through 10
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
A =
    Columns 1 through 8
       0     0     0     0     0     0     0     0
       1     1     1     1     1     1     1     1
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
       0     0     0     0     0     0     0     0
    Columns 9 through 10
       0     0
       1     1
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
A =
    Columns 1 through 8
       0     0     0     0     1     0     0     0
       1     1     1     1     1     1     1     1
       0     0     0     0     1     0     0     0
       0     0     0     0     1     0     0     0
       0     0     0     0     1     0     0     0
       0     0     0     0     1     0     0     0
       0     0     0     0     1     0     0     0
       0     0     0     0     1     0     0     0
       0     0     0     0     1     0     0     0
       0     0     0     0     1     0     0     0
    Columns 9 through 10
       0     0
       1     1
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
       0     0
>>
zeros(10,10) which is the same as zeros(10) creates 10 by 10 matrix with zeros and with the above code ones are filled in 2nd row and in 5th column.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

