whats the meaning of these question? " Subscripted assignment dimension mismatch."

5 ビュー (過去 30 日間)
in an optimization problem i encounter with this message . whats the problem and how can i solve it?
  5 件のコメント
Walter Roberson
Walter Roberson 2018 年 8 月 13 日
Renzo Lanfranco also commented
Rude answer
Walter Roberson
Walter Roberson 2018 年 8 月 13 日
Renzo Lanfranco:
The response was not rude. It was correct: the way to solve the problem is to learn how to use the debugger.

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

採用された回答

AJ von Alt
AJ von Alt 2014 年 1 月 28 日
編集済み: AJ von Alt 2014 年 1 月 28 日
This error occurs when the dimensions of the array resulting from the assignment expression do not match the explicitly defined dimensions of the assignment variable.
Basically, the dimensions of the arrays on the left and right hand side of the equals sign don't match.
The code
A(1,1) = [1 2 3; 4 5 6; 7 8 9]; %you can't store a 3x3 matrix in a 1x1 matrix
produces the error
Subscripted assignment dimension mismatch.
because A(1,1) is size 1x1 and [1 2 3; 4 5 6; 7 8 9]; is size 3x3.
You can solve this error by making sure that the dimensions match.
A(1:3,1:3) = [1 2 3; 4 5 6; 7 8 9]; % Doesn't error because both arrays are 3x3

その他の回答 (0 件)

カテゴリ

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