Creating matrices automatically WITH FOR LOOP

44 vues (au cours des 30 derniers jours)
Selman
Selman le 2 Déc 2013
Commenté : Walter Roberson le 2 Déc 2013
Hi,
Is there a way to create matrices automatically with for loop in Matlab? For example:
For i=1:3
A(i)=[ i ; i+1 ];
end
After running the code I want to have 3 matrices with the following elements:
A1 = [ 1 ; 2 ]
A2 = [ 2 ; 3 ]
A3 = [ 3 ; 4 ]
The problem here is to write A(i) in the correct format in for loop? How can I write it?

Réponse acceptée

sixwwwwww
sixwwwwww le 2 Déc 2013
Modifié(e) : sixwwwwww le 2 Déc 2013
Dear Selman, you can use:
A{i} = [i; i + 1]
Here A will be a cell array whose each element will be your desired matrix
  5 commentaires
sixwwwwww
sixwwwwww le 2 Déc 2013
you are welcome

Connectez-vous pour commenter.

Plus de réponses (0)

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!

Translated by