Hi
I downloaded data from an excel worksheet to matlab. Matlab creates a table. Matlab inserts the first row of the data in excel (which are dates in the format 2/28/2019) as the variable names in the format x2_28_2019. Isn't it possible to extract the original variable names in Properties.VariableDescriptions (without mentioning "Original column heading:"). So that I can transform the dates coming from excel to dateformat in matlab?

 채택된 답변

Peter Perkins
Peter Perkins 2019년 3월 15일

0 개 추천

It's easy to turn 'x2_28_2019' into a datetime, that's just
>> datetime('x2_28_2019','InputFormat','''x''MM_dd_yyyy')
ans =
datetime
28-Feb-2019
You can do that on t.Properties.VariableNames to convert them all.
The more difficult question is what do you want to do with them next? You can't use datetimes as the variable names of a table, although you can use them as the row times of a timetable -- rotating 90 deg, in effect.

추가 답변 (1개)

dpb
dpb 2019년 3월 15일
편집: dpb 2019년 3월 15일

1 개 추천

...,'ReadVariableNames',0); % use the named parameters as needed
See
doc readtable
Also, in general,
doc detectImportOptions
and Matlab will probably auto-detect the situation for you...

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

질문:

BdS
2019년 3월 15일

편집:

dpb
2019년 3월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by