Plotting elements corresponding to a matrix

9 ビュー (過去 30 日間)
Hari krishnan
Hari krishnan 2019 年 5 月 5 日
コメント済み: Hari krishnan 2019 年 5 月 6 日
I have a matrix as shown below.
NaN 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000
0.2000 26.0000 27.3000 56.0000 63.0000 32.0000 49.0000
0.4000 26.8300 30.0000 59.0000 66.0000 38.0000 51.0000
0.6000 29.8300 34.0000 61.0000 71.0000 41.0000 54.0000
0.8000 31.5200 35.0000 65.0000 74.0000 43.0000 52.0000
1.0000 33.0000 37.0000 67.0000 79.5000 48.0000 47.0000
1.2000 34.3700 39.0000 69.0000 81.2000 50.0000 45.0000
1.4000 36.3700 40.0000 72.0000 84.0000 52.0000 42.0000
The first column corresponds to the time and first row corresponds to name of object. Under the objects name, the corresponding X and Y coordinates are shown in columns. Can anyone give me an idea on how to plot all objects together across time?
  4 件のコメント
Raj
Raj 2019 年 5 月 6 日
You want to plot Y versus X for each object or both X and Y versus time for each object or you are looking for a 3 dimensional plot here?
Hari krishnan
Hari krishnan 2019 年 5 月 6 日
I want to plot X and Y against each other with the time beeing displayed as a title. It's a 2D plot

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

採用された回答

Raj
Raj 2019 年 5 月 6 日
If I understand your problem statement correctly, your code should look something like this:
A=[NaN 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000
0.2000 26.0000 27.3000 56.0000 63.0000 32.0000 49.0000
0.4000 26.8300 30.0000 59.0000 66.0000 38.0000 51.0000
0.6000 29.8300 34.0000 61.0000 71.0000 41.0000 54.0000
0.8000 31.5200 35.0000 65.0000 74.0000 43.0000 52.0000
1.0000 33.0000 37.0000 67.0000 79.5000 48.0000 47.0000
1.2000 34.3700 39.0000 69.0000 81.2000 50.0000 45.0000
1.4000 36.3700 40.0000 72.0000 84.0000 52.0000 42.0000];
X1=zeros(7,1); % pre define arrays
Y1=zeros(7,1);
for j=2:2:6
for i=2:8
X1(i-1,1)=A(i,j);
Y1(i-1,1)=A(i,j+1);
end
hold all
grid on
plot(X1,Y1)
title('time=0.2;0.4;0.6;0.8;1.0;1.2;1.4') % Display time as title
if j==6 % Put legend at the end
legend('object5Y vs Object5X','object6Y vs Object6X','object7Y vs Object7X')
end
end
  1 件のコメント
Hari krishnan
Hari krishnan 2019 年 5 月 6 日
@Raj, Thank you very much.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by