How to solve dimension mismatch?
3 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have a matrix named "X" that firstly starts with 27x2 but then it goes into a while loop and after some calculations the row value and the elements change, sometimes to a greater value than 27 and sometimes a lower value for example: sometimes it becomes 35x2 and sometimes it becomes 12x2, and I keep this as a new matrix "Y" . And when I want to put that Y matrix inside of X, it gives dimension mismatch. Is there a way to solve this, if so I will appreciate your help.
Thanks!
0 件のコメント
回答 (1 件)
Walter Roberson
2019 年 11 月 8 日
S=size(Y);
X(1:S(1),1:S(2)) = Y;
This will extend X if needed, but if the new Y is smaller then only the "upper left" will be changed to Y leaving the rest unchanged.
2 件のコメント
Walter Roberson
2019 年 11 月 8 日
You need to define the results that you want in that case. It sounds like you want something different than just X=Y; but we do not know what.
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!