MATLAB Answers

From matrix to timetable

38 ビュー (過去 30 日間)
Rub Ron
Rub Ron 2019 年 8 月 14 日
コメント済み: Steven Lord 2019 年 8 月 14 日
I have a matrix bb (class:double), where the first column is the time in numeric format. I want to convert this matrix to a timetable:
I can do it with this line:
zz=array2timetable(bb(:,2:end),'RowTimes',datetime(bb(:,1)','ConvertFrom','excel'))
But to me does not look optimal as I have to do it for several long matrices inside an array. Is there a better way to do so?

  0 件のコメント

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

採用された回答

Neuropragmatist
Neuropragmatist 2019 年 8 月 14 日
I think what you have there is about as efficient as you can get.
M.

  1 件のコメント

Steven Lord
Steven Lord 2019 年 8 月 14 日
One minor optimization, to reduce typing, would be to make that into a function or an anonymous function. That would at least save you having to retype the parameters to array2timetable repeatedly.
makeTT = @(x) array2timetable(x(:, 2:end), ...
'RowTimes', x(:, 1), ...
'ConvertFrom', 'excel');
y1 = makeTT(x1);
y2 = makeTT(x2);
% etc

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by