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 Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2013년 7월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by