フィルターのクリア

Selecting unique tracks to plot multiple lines in a figure?

1 回表示 (過去 30 日間)
Jaclyn
Jaclyn 2013 年 7 月 30 日
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.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 30 日
編集済み: Azzi Abdelmalek 2013 年 7 月 30 日
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}
  1 件のコメント
Jaclyn
Jaclyn 2013 年 7 月 30 日
This works perfect, thank you!!!

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

その他の回答 (1 件)

dpb
dpb 2013 年 7 月 30 日
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...

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by