フィルターのクリア

how to plot different figures from the same matrix

1 回表示 (過去 30 日間)
Thar
Thar 2015 年 3 月 21 日
コメント済み: Konstantinos Sofos 2015 年 3 月 21 日
Hi!
I have a matrix with 1376x3 dimensions. First column is the day, second the time and third my measurements. The matrix is:
8 7.56 316
8 8.45 319.56
8 10.78 317.4
9 12.76 323.98
9 14.27 356.89
10 13.45 346.12
10 14.2 312.43
and so on, until the day 365. (some days are missing).
I want to plot the second and third columns for each day separately.
Any ideas?
Thank you!
  2 件のコメント
Geoff Hayes
Geoff Hayes 2015 年 3 月 21 日
Thodoris - do you want all of this data on one figure or do you want one figure for each day of the year? I can't imagine you wanting up to 365 figures for all of this data so please describe what you would like to obtain and what you have attempted so far.
Thar
Thar 2015 年 3 月 21 日
I want one figure for each day of the year. But i can't separate and keep the data for each day.

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

採用された回答

the cyclist
the cyclist 2015 年 3 月 21 日
Try this
D = [
8 7.56 316
8 8.45 319.56
8 10.78 317.4
9 12.76 323.98
9 14.27 356.89
10 13.45 346.12
10 14.2 312.43]
uniqueDays = unique(D(:,1));
numberUniqueDays = numel(uniqueDays);
for nd = 1:numberUniqueDays
indexToThisDay = D(:,1)==uniqueDays(nd);
figure
plot(D(indexToThisDay,2),D(indexToThisDay,3))
end
  2 件のコメント
Thar
Thar 2015 年 3 月 21 日
Is there way to write the number of the day on the graph?
Thank you!
Konstantinos Sofos
Konstantinos Sofos 2015 年 3 月 21 日
use after plot...
title(num2str(uniqueDays(nd)))

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

その他の回答 (1 件)

Konstantinos Sofos
Konstantinos Sofos 2015 年 3 月 21 日
Hi Thodoris,
As i understood in each day you (may) have more that one timestamps of measurements and you want a figure (or plot??) for each corresponding day with its measurements. So i imagine that your basic problem is an indexation problem. (Are your days format as you described i.e. 1,2,3... or in a date number format?)
Assuming the matrix that you gave us
A =
8.0000 7.5600 316.0000
8.0000 8.4500 319.5600
8.0000 10.7800 317.4000
9.0000 12.7600 323.9800
9.0000 14.2700 356.8900
10.0000 13.4500 346.1200
10.0000 14.2000 312.4300
you can find the indexation of the days as
idx=find(diff(A(:,1)) == 1) + 1; % day indexation
idx = [1;idx;length(A)]; % consider the start and the end of the time period
%plotting : Create a figure for each day
for i=1:numel(idx)-1
figure
x = A(idx(i):idx(i+1)-1,2);
y = A(idx(i):idx(i+1)-1,3);
plot(x,y,'r*-')
end
So this will give you 365 figures...is this really that you want?
Regards

カテゴリ

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