Date numbers in double to datestring matrix

2 ビュー (過去 30 日間)
Evan Watts
Evan Watts 2018 年 4 月 25 日
コメント済み: Peter Perkins 2018 年 4 月 26 日
I have a 31x3 double with the first column being date serial numbers from low to high, and the next 2 columns being X an Y. I would simply like to create a matrix that is more user friendly, so that someone can click on it and see actual date strings corresponding with the X and Y values. Is there any effective way of doing this? I have been battling with datestr, as it doesn't like putting things back into a double. Thoughts?

採用された回答

njj1
njj1 2018 年 4 月 25 日
You cannot put date strings and numerical data into a single matrix. You could use a cell if you wanted. For example:
X_new{1,1} = datestr(X_old(:,1)); %first cell array is the date strings
X_new{1,2} = X_old(:,2:end); %second cell is the X,Y data matrix
  1 件のコメント
Peter Perkins
Peter Perkins 2018 年 4 月 26 日
You will be much happier with a table or (in R2016b or later) a timetable than with a cell array. You'll also be happier if you use datetimes rather than datenums and datestrs.

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2018 年 4 月 25 日
If you're using release R2016b or later, consider representing your times as a datetime vector and storing your data in a timetable with that datetime vector as its time vector.

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by