I want Seperate Matrices for different values of n . (Im new to Matlab)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Maruti Patil
am 13 Apr. 2015
Bearbeitet: Maruti Patil
am 14 Apr. 2015
suppose I have a matrix
A=[1+n 3+n; 2 6+n];
and n=1:6;
how to get 6 different matrices A1 A2 A3....A6??.
I tried A(n)=[1+n 3+n; 2 6+n]; but it is giving error.. Pls help Thanx.
0 Kommentare
Akzeptierte Antwort
Guillaume
am 13 Apr. 2015
Bearbeitet: Guillaume
am 13 Apr. 2015
Use a cell array (or a 3d matrix) to store your different matrices. Use curly braces instead of round braces to index cell arrays. That is:
for i = 1:6
A{i} = [1+i 3+i; 2 6+i];
end
However, I would not use i as a variable name, as it is also the symbol for the imaginary unit. You're really asking for trouble here, because the matrix expression will work even if you don't define i, but will give you a completely different result. Witness:
clear i %i is not defined
A = [1+i 3+i; 2 6+i] %and the expression now refers to the imaginary unit
0 Kommentare
Weitere Antworten (1)
James Tursa
am 13 Apr. 2015
Bearbeitet: James Tursa
am 13 Apr. 2015
Don't do this! See these links for better solutions:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!