MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

0

what wrong about this error

ahmed hamdy さんによって質問されました 2019 年 5 月 21 日
最新アクティビティ ahmed hamdy さんによって コメントされました 2019 年 5 月 22 日
In an assignment A(I) = B, the number of elements in B and
I must be the same.

  6 件のコメント

ahmed hamdy 2019 年 5 月 22 日
sorry code repeated
Rik
2019 年 5 月 22 日
Code Analyzer found 142 warnings for your code. Maybe you should deal with those...
If you had posted the error message, we wouldn't need to search through over 400 lines of barely commented code to find the error. We are also missing the loadcase function (and the files it presumably loads) and the input to actually run the function.
The answer James has given is already the answer to your question. If you want specific guidance, post a specific part of the code. Use the debugger (click the 'pause on error' option). Then you can see the sizes of the arrays in the offending line of code.
Also note that it is generally a good idea to try to keep the size of your functions small and use subfunctions. Also, don't use global variables.
ahmed hamdy 2019 年 5 月 22 日
thanks alot

サインイン to comment.

タグ

1 件の回答

James Tursa
回答者: James Tursa
2019 年 5 月 22 日
編集済み: James Tursa
2019 年 5 月 22 日

The error message appears when you have a mismatch in the number of elements on the rhs and the number of elements on the lhs. E.g.,
>> x = 1:10
x =
1 2 3 4 5 6 7 8 9 10
>> y = 40:43
y =
40 41 42 43
>> x(1:5) = y % <-- Try to assign 4 elements into 5 elements doesn't work
In an assignment A(:) = B, the number of elements in A and B must be the same.
>> x(1:4) = y % <-- Assigning 4 elements into 4 elements does work
x =
40 41 42 43 5 6 7 8 9 10

  0 件のコメント

サインイン to comment.



Translated by