Storing Hour Minute & Second in Matlab workspace

1 view (last 30 days)
Bryan
Bryan on 13 Sep 2015
Edited: Bryan on 14 Sep 2015
I am trying to plot time against a voltage in hours, minutes and seconds. Is there a way of saving time in this format as a single column array of 1-235 please? :-)
Thanks in advance.
Edited for below, I have 234 time samples over a 24 hour period and each sample has a voltage value, my problem is with using hh:mm:ss, I am trying to import the values from excel for example 11:12:12 but Matlab just sees it as a general default value of 42248.049 seconds, it does this for all of my time values.
Also is there a way of using values I an array one after the other? suppose the are just values in time, is it possible to generate them as a sine wave as (the array value*sin(2*pi*f*t)) against the time values above?
  1 Comment
Walter Roberson
Walter Roberson on 13 Sep 2015
What form is your time data in at the moment?
Note: your maximum suggested value of 235 is less than 4 minutes. If you have as much as 1 hour of data you will need values at least 3600.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 13 Sep 2015
Which MATLAB version are you using?
If you are using an earlier version but have the Finance Toolbox then see http://www.mathworks.com/help/finance/x2mdate.html
I get confused by the documentation, but my tests suggest that the manual conversion (if your MATLAB is not sufficiently new to have datetime() objects) is
matlab_serial_date = excel_numeric_date + datenum('1900-01-01') - 2;
Once you have the MATLAB serial date you can datevec() it to extract the hour and minute fields. Or since what you want to do with it is plot, leave it in matlab serial date form and use it as your x axis and use
datetick('x', 'hh:mm:ss')

Categories

Find more on Dates and Time in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!