フィルターのクリア

Tried to change the diagonal elements of a magic square. Could not understand the error message.

1 回表示 (過去 30 日間)
a= magic(6), diag(a)=[1 0 2 0 3 4]
Error message that I got was "Subscripted assignment dimension mismatch".
Do not understand why this happened, when you can easily replace a column or row of the matrix with similar syntax.

採用された回答

Matt J
Matt J 2017 年 12 月 28 日
編集済み: Matt J 2017 年 12 月 28 日
You cannot put a function call on the left hand side of an assignment statement. Do this instead,
a(1:7:end)=[1 0 2 0 3 4]

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by