Creating figures according to slice number

Hi I have data that contains slice number and coordinates. first column is slice number (changing), the last two columns are x y coordinates. I want to create figures of the coordinates with the same slice number, and once the slice number change, a new figure is generated. Could you help me? Here is what I have so far.
slice=realdata(:,3);
row=realdata(:,4);
col=realdata(:,5);
correctlength=length(slice)-1;
for i=1:correctlength
if slice(i)==slice(i+1)
plot(row(i),col(i))
end
end

 採用された回答

the cyclist
the cyclist 2013 年 7 月 9 日
編集済み: the cyclist 2013 年 7 月 9 日

0 投票

Here is a self-contained example with some made-up data.
% Made up data with three "slices", each with a different number of points
realdata = [rand(9,2),[1;1;1;1;2;2;2;3;3],rand(9,5)];
slice=realdata(:,3);
row=realdata(:,4);
col=realdata(:,5);
correctlength=length(slice);
for i=1:correctlength
if (i==1) || (slice(i)~=slice(i-1))
figure
hold on
end
plot(row(i),col(i),'.')
end

2 件のコメント

Tina
Tina 2013 年 7 月 9 日
Thank you!
Tina
Tina 2013 年 7 月 9 日
yes the edited one worked perfectly. the first version was missing the last slice. thanks!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by