How to set limit of cell?

5 ビュー (過去 30 日間)
Veronika
Veronika 2017 年 4 月 4 日
コメント済み: Veronika 2017 年 4 月 5 日
Dear all,
I have this part of code:
for i=1:numel(tmp)
tmp2 = shape.spine{i};
if numel(tmp2)>2
cnt=cnt+1;
t=[t i];
plot(tmp2(:,2),tmp2(:,1), 'o-y')
end
legend('Okolí hrudníku', 'Páteř + žebra');
end
tmp = tmp2;
and after this for loop there is this error:
Index exceeds matrix dimensions.
Error in DP_segment_final>Pater_Callback (line 456)
tmp2 = shape.spine{i};
I think, that there is problem in struct shape in cell spine, but I don´t know, how to extend or set limits of this cell. Or exist some other solutions for my problem?
Thank you for your answers.

採用された回答

Jan
Jan 2017 年 4 月 4 日
If you want to create a loop over the existing elements of a cell, use the number of elements of this cell as upper limit:
for i = 1:numel(shape.spine)
tmp2 = shape.spine{i};
...
  1 件のコメント
Veronika
Veronika 2017 年 4 月 5 日
Thank you for your answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by