How to plot time format
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have two time matrices of t1=3x250 and t3=3x450 with 3 columns representing hour, minute and second as integers. I also have two vectors X1 and X2 of size 1x450 and 1x250 respectively. I know on the SAME graph want to plot X1 and x2 against t1 and t2 where each observation on x axis would read in format hour:minute:second. Probably very easy to do. Could anybody guide me please?
0 commentaires
Réponses (2)
Star Strider
le 14 Jan 2017
It would be easier with your data.
Here is one possibility with created data:
t1 = [0 1 2; 0 2 3; 1 1 10; 1 39 45]; % Original ‘t1’ ‘Hour Minute Second’ Matrix
t1a = [repmat([2017 0 0], size(t1,1), 1) t1]; % Concatenate With ‘[year month day]’
dnv1 = datenum(t1a); % Convert To Date Numbers
x1 = rand(size(dnv1)); % Data ‘x1’
t2 = [0 2 10; 0 3 5; 1 2 20; 2 30 15]; % Original ‘t2’ ‘Hour Minute Second’ Matrix
t2a = [repmat([2017 0 0], size(t1,1), 1) t2];
dnv2 = datenum(t2a);
x2 = rand(size(dnv2));
figure(1)
plot(dnv1, x1)
hold on
plot(dnv2, x2)
hold off
datetick('x', 'hh:mm:ss', 'keepticks')
1 commentaire
Steven Lord
le 4 Mai 2021
Now you'd probably want to use a duration array.
h = randi(3, 1, 10);
m = randi([0 59], 1, 10);
s = randi([0 59], 1, 10);
D = sort(duration(h, m, s));
data = minutes(D-D(1)).^2; % minutes from start squared
plot(D, data, 'o-')
0 commentaires
Voir également
Catégories
En savoir plus sur Dates and Time 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!