How to change an ecxel number to time and add to a plot

2 ビュー (過去 30 日間)
Teresa Phillips
Teresa Phillips 2016 年 8 月 16 日
コメント済み: Walter Roberson 2016 年 8 月 17 日
I have imported an excel spreadsheet with a time variable (in excel the format is HH:MM:SS AM, but I would like it displayed as MM:SS) which when imported into matlab is shown as a number.
Currently, the data sits in a 130x22 table of which 'time' is :,1
I have used
TestTableTime = datestr(TestTable.Time, 'HH:MM:SS');
to convert the time which was effective except it now sits in a 130x68 char array. Is there a way in which I can change the values in my current table (named TestTable) or can the values be placed into a format in which I can use it as a variable for an x-axis on a plot?

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 8 月 16 日
If you have R2014b or later then you can use datetime objects as the x axis values.
If you are using R2014a or earlier you need to use serial date numbers together with datetick()
  2 件のコメント
Teresa Phillips
Teresa Phillips 2016 年 8 月 16 日
Sorry I am not exactly sure how to use this information to develop an x-axis
Walter Roberson
Walter Roberson 2016 年 8 月 17 日
TestTableTime = datetime(TestTable.Time, 'InputFormat', 'HH:MM:SS');
example_data = rand(size(TestTableTime));
plot(TestTableTime, example_data);

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

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by