How to change the first row of a matrix to be the same as an already programmed vector?
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Stephen23
2017 年 1 月 29 日
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
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!