plotting the following in matlab impossible?

I would like to plot time in the x axis vs data(Amplitude) on the y axis, moreover my time is in a cell and the data is in a double:;
Name, Size , Class
x= Rodtime , 238451x1, cell
Name , Size, Class
y= RPeakAmplitude1, 238451x1 , double
Rodtime(1:9)
ans =
'12:00:08.172'
'12:00:13.270'
'12:00:15.668'
'12:00:15.769'
'12:00:24.749'
'12:00:24.833'
'12:00:25.293'
'12:00:25.874'
'12:00:27.000'
...
How could I plot this graph? thank you in advance Rod

回答 (1 件)

dpb
dpb 2015 年 8 月 12 日

0 投票

dn=datenum(Rodtime); % convert to date num's
plot(dn,RPeakAmplitude1)
datetick('x')
Adjust x limits, tick spacing as desired. If you have late version of Matlab there's also a newer date/time class with some supposedly simpler methods altho I've not had the opportunity to try it...

5 件のコメント

rfrg
rfrg 2015 年 8 月 12 日
thank you so much for your time and reply, datetick does not seem work because I am not plotting serial date numbers in my implementation.
Star Strider
Star Strider 2015 年 8 月 12 日
What are you plotting?
Specific Questions produce specific Answers.
dpb
dpb 2015 年 8 月 12 日
Then, as shown, convert to datenums. If you want to use the Matlab time axes, that's what they're based on (either historic datetick or the newer time class is still a date number inside; just different methods).
Walter Roberson
Walter Roberson 2015 年 8 月 12 日
You can specify the time format for datetick, such as
datetick('x', 'HH:MM')
dpb
dpb 2015 年 8 月 12 日
but to be completely clear for the OP, the x-axis must be in datenumbers for it to be interpreted correctly.

この質問は閉じられています。

質問済み:

2015 年 8 月 12 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by