Subscripted assignment dimension mismatch

조회 수: 13 (최근 30일)
Antonio Sechi
Antonio Sechi 2017년 11월 10일
댓글: Antonio Sechi 2017년 11월 13일
Dear All,
I have recently upgraded to R2016b (from R2013b). When I run my code, I get the following error message:
Subscripted assignment dimension mismatch
Since I have not modified my code, I do not see any logic in it. Do you have any idea about what happened?
Thank you in advance, Antonio Sechi
P.S.: I use a MacBook Pro Retina running 10.12.6.
  댓글 수: 8
Guillaume
Guillaume 2017년 11월 13일
Well, clearly the sizes don't match. objects is (nearly) twice as big as m in the first two dimensions. How is the size of objects determined?
Antonio Sechi
Antonio Sechi 2017년 11월 13일
at least the first three dimensions of objects correspond to the original data, which is a multiTIFF 662x647 containing 50 frames (attached is one frame). I do not know how objects size is determined, nor I have the chance to get in contact with the persons that wrote the code. Thank you for now.

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2017년 11월 13일
편집: Walter Roberson 2017년 11월 13일
What is size(m) and size(Objects) at the time of the failure?
R2016b introduced implicit expansion, similar to bsxfun. For example (1:2).' + (3:5) would previously have generated an error because of trying to add a 2 x 1 to a 1 x 3, but it is now equivalent to bsxfun(@plus, (1:2).', (3:5)) . This change tended to uncover some subtle bugs in code.
But other than that, you might possibly need
objects(:, :, i, :) = permute(m, [1 2 4 3]);
because your 3rd dimension of m is not a scalar to match against the scalar i.

Guillaume
Guillaume 2017년 11월 13일
In R2014 (a or b, can't remember) mathworks completely rewrote the graphics engine of matlab. With that rewrite came a lot of changes of behaviour (e.g. graphics handle are no longer numeric). It looks like your code is grabbing some figure frame (with your mygetframe function). Possibly the frame is now a different size than you expect (since we don't see how you declared object we don't know if you hardcoded the size) or possibly your function does not even return a frame anymore.
In any case, since your code involves graphics, you will have to use the debugger to check that all these functions that deal with graphics still work as expected.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by