フィルターのクリア

How to plot time format

8 ビュー (過去 30 日間)
jenka
jenka 2017 年 1 月 14 日
回答済み: Steven Lord 2021 年 5 月 4 日
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?

回答 (2 件)

Star Strider
Star Strider 2017 年 1 月 14 日
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 件のコメント
Raidah Zaman
Raidah Zaman 2021 年 5 月 4 日
Thank you! I was geniunely able to learn from this.

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


Steven Lord
Steven Lord 2021 年 5 月 4 日
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-')

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by