How to change the first row of a matrix to be the same as an already programmed vector?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
So I have vector x
x= 2:4:18
I have the matrix M
M= magic(5)
M=
17 24 18 8 15
23 5 7 2 16
4 6 13 20 6
10 12 19 21 3
11 14 25 2 9
I want the first row of M to be equal to x I write
M(1,:)=x
but I get the error "The expression to the left of the equals sign is not a valid target for an assignment."
1 commentaire
Stephen23
le 29 Jan 2017
It works for me:
>> M = magic(5)
M =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
>> x = 2:4:18
x =
2 6 10 14 18
>> M(1,:) = x
M =
2 6 10 14 18
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
Réponses (0)
Voir également
Catégories
En savoir plus sur Whos 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!