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

 Akzeptierte Antwort

the cyclist
the cyclist am 9 Jul. 2013
Bearbeitet: the cyclist am 9 Jul. 2013

0 Stimmen

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 Kommentare

Tina
Tina am 9 Jul. 2013
Thank you!
Tina
Tina am 9 Jul. 2013
yes the edited one worked perfectly. the first version was missing the last slice. thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by