フィルターのクリア

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 Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by