From matrix to timetable

조회 수: 13 (최근 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?

채택된 답변

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개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by