- Most efficient way:
I want to store data in a matrix from a for loop using non integer indexing
    2 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Arjun Upadhyay
 il 15 Ago 2020
  
    
    
    
    
    Commentato: Arjun Upadhyay
 il 19 Ago 2020
            Here is the simple version of my code. 
x = [5:0.1:20];
for v = 1:.1:10
    R = v.*x;
     mat(v,:)=R;
end
    I want to store data in a matrix 'mat' for each iteration . Please suggest me how to do this.
0 Commenti
Risposta accettata
  Sulaymon Eshkabilov
      
 il 15 Ago 2020
        Hi,
There are several ways of doing it:
x = [5:0.1:20];
v = (1:.1:10)';
MAT=v.*x;
2. Least efficient way:
for ii=1:numel(v)
     MAT(ii,:)=v(ii)*x;
end
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!

