how to plot different figures from the same matrix
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Thar
il 21 Mar 2015
Commentato: Konstantinos Sofos
il 21 Mar 2015
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 Commenti
Geoff Hayes
il 21 Mar 2015
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.
Risposta accettata
the cyclist
il 21 Mar 2015
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
Più risposte (1)
Konstantinos Sofos
il 21 Mar 2015
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
0 Commenti
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!