creating a new matrix from an obtained matix?
Mostra commenti meno recenti
Hello. If I already have a matrix [1 2 3; 4 5 6; 7 8 9], how can I add 0 to its every row by a command?
Thank you.
Risposte (2)
Alan Stevens
il 15 Ago 2020
Something like:
M = [1 2 3; 4 5 6; 7 8 9];
Mplus = [M zeros(3,1)]
Mplus =
1 2 3 0
4 5 6 0
7 8 9 0
Alwys assuming you want the zeros as the last column.
metin yilmaz
il 15 Ago 2020
Modificato: metin yilmaz
il 15 Ago 2020
0 voti
5 Commenti
Alan Stevens
il 15 Ago 2020
Mplus =[2*ones(3,1) M]
metin yilmaz
il 15 Ago 2020
Alan Stevens
il 15 Ago 2020
Yes, that works ok.
metin yilmaz
il 15 Ago 2020
Alan Stevens
il 15 Ago 2020
Try:
M = [M(:,1:2) 2*ones(3,1) M(:,3:end)];
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!