Change in matrix without re-writing

1 回表示 (過去 30 日間)
Rand Renwar
Rand Renwar 2016 年 9 月 29 日
コメント済み: Rand Renwar 2016 年 9 月 29 日
So if I have a 2x4 matrix, how do I change a number in that matrix without having to re-write the entire matrix?
M = [ 1 3 5 2
-1 0 1 7];
(M is one big matrix, I'm sorry but I'm quite new here) If I wanted to change the 7 to a 8 for instance, what would be the fastest way?
Thanks

採用された回答

Geoff Hayes
Geoff Hayes 2016 年 9 月 29 日
Rand - since the 7 is in the fourth column of the second row, then the easiest way to change this to an 8 is as follows
M(2,4) = 8;
  1 件のコメント
Rand Renwar
Rand Renwar 2016 年 9 月 29 日
Thank you very much!

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2016 年 9 月 29 日
A = zeros(5, 5)
A(3, 4) = 7
A(10) = 2
A(A > 5) = 5

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by