how to insert diganole of zeros in to matrix without using loops ?
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    tomer polsky
 il 3 Mar 2019
  
    
    
    
    
    Modificato: madhan ravi
      
      
 il 3 Mar 2019
            my question is simple how to change the main diagonel of nXn of random numers and change the main diagonle to zeroes ? 
without using loops ? 
0 Commenti
Risposta accettata
  madhan ravi
      
      
 il 3 Mar 2019
        a(logical(eye(size(a,1))))=0 % where a is your matrix
2 Commenti
  madhan ravi
      
      
 il 3 Mar 2019
				
      Modificato: madhan ravi
      
      
 il 3 Mar 2019
  
			logical indexing 
Alternative (faster):
a(1:size(a,1)+1:end)=0
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!