Effacer les filtres
Effacer les filtres

Selecting unique tracks to plot multiple lines in a figure?

1 vue (au cours des 30 derniers jours)
Jaclyn
Jaclyn le 30 Juil 2013
I have a dataset of tracks and associated (x,y) points which are identified by a track ID, for ex.:
trackID, X, Y
1 45 75
1 50 80
1 55 85
3 10 30
3 15 35
I need to plot all these tracks (which all vary in number of points) on the same figure as individual lines. So far all I have is each track ID, is there a way to loop through and pull out each track's coordinates to put in a single plot?
[trackID,ia,ic] = unique(ds(:,1));
The dataset has 45000 points and I'm using Matlab 2011.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 30 Juil 2013
Modifié(e) : Azzi Abdelmalek le 30 Juil 2013
c1=A(:,1);
idx=unique(c1);
n=numel(idx);
c=cell(n,1);
for k=1:n
c{k}=A(A(:,1)==idx(k),2:3);
end
c{1}
c{2}

Plus de réponses (1)

dpb
dpb le 30 Juil 2013
The loop solution...
u=unique(ds(:,1));
ix=u(1)==ds(:,1); % find first set locations
plot(ds(ix,2),ds(ix,3)) % plot them
hold on % prep for remaining
for i=2:length(u) % rest
ix=u(i)==ds(:,1);
plot(ds(ix,2),ds(ix,3))
end
Likely want to modify line colors, add legends, etc., but that's the gist of it...

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by