필터 지우기
필터 지우기

Error: Subscripted assignment dimension mismatch.

조회 수: 1 (최근 30일)
pamela sulis
pamela sulis 2016년 3월 21일
편집: Stephen23 2016년 3월 21일
Hi, I have a struct semanticTrajCompact: after traspose the content in every cell of semanticTrajCompact(1,4).locID, I want to delete consecutive repeated values. I have create this code:
for j=1:size(semanticTrajCompact(1,4).locID,1)
y=semanticTrajCompact(1,4).locID{j,1}'
newY=y([1,diff(y)]~=0)
z(j,1)=newY
end
but it gives me this error:
Subscripted assignment dimension mismatch.
Error in a (line 4)
z(j,1)=newY
I don't understand why, can you help me?

채택된 답변

Stephen23
Stephen23 2016년 3월 21일
편집: Stephen23 2016년 3월 21일
Because j is a scalar then z(j,1) refers to one element of z. There is nothing preventing newY from having multiple values (in fact this seems to be the point of your code). So you are trying to fit multiple elements into one element. Thus the error.
Basically you are doing this:
>> X(1,1) = 1:3
Subscripted assignment dimension mismatch.
Because multiple numeric elements do not fit into one numeric element.
You might like to use a cell array instead:
z{j,1} = newY;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by