필터 지우기
필터 지우기

How to solve dimension mismatch?

조회 수: 3 (최근 30일)
Iremsu Savas
Iremsu Savas 2019년 11월 8일
댓글: Walter Roberson 2019년 11월 8일
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!

답변 (1개)

Walter Roberson
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
Iremsu Savas
Iremsu Savas 2019년 11월 8일
Thank you for your answer, when Y is smaller, if just the upper left changes and the others remain the same, it is a huge problem for the code flow. Is there something you suggest to avoid this?
Walter Roberson
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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by