Store value in Matrix
    5 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
Hello,
I want to store the value in the matrix form using for loop.
For example: Let's say I have a matrix A (2*2 matrix)
A = [1 2;
     3 4]
But the output should be:
A = [1 0 0 0
     1 2 0 0
     1 2 3 0
     1 2 3 4]
Can somebody tell me how to do this?
Thank you very much!
0 commentaires
Réponses (2)
  Star Strider
      
      
 le 21 Jan 2017
        One approach:
A = [1 2;
     3 4];
A = A';
B = repmat(A(:)',numel(A),1);
Result = tril(B)
Result =
     1     0     0     0
     1     2     0     0
     1     2     3     0
     1     2     3     4
2 commentaires
Voir également
Catégories
				En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


