Time reading in matlab
显示 更早的评论
Hi, I have a data set, using matlab I need to read all the data.But the date and time reading is not working.Please help me.
8 个评论
Walter Roberson
2019-8-23
What file format is the dataset in? What code are you trying? Which MATLAB release are you using?
Silpa K
2019-8-23
Walter Roberson
2019-8-23
.catalog do not appear to be .xlsx so I would not expect xlsread() to be able to read them.
But if somehow you got some useful information using xlsread() then I suggest you try using readtable() which is an improved xlsx interface.
Silpa K
2019-8-23
Walter Roberson
2019-8-23
I need a sample input file to test with.
Silpa K
2019-8-24
Walter Roberson
2019-8-24
Zip the file and attach the .zip here.
Silpa K
2019-8-24
采纳的回答
更多回答(1 个)
Walter Roberson
2019-8-24
%set up
opt = detectImportOptions('1932.catalog', 'FileType', 'text', 'readvariablenames', false, 'HeaderLines', 10);
opt = setvartype(opt, 1, 'datetime');
opt = setvaropts(opt,1,'InputFormat', 'yyyy/MM/dd');
opt.VariableNames = {'Date', 'Time', 'ET', 'GT', 'MAG', 'M', 'LAT', 'LON', 'DEPTH', 'Q', 'EVID', 'NPH', 'NGRM'};
%read the file
datatable = readtable('1932.catalog', opt);
%throw away the garbage last entries
datatable = rmmissing(datatable);
%create a composite date/time from the date and time fields
datatable.DateTime = datatable.Date + datatable.Time;
datatable.DateTime.Format = 'dd-MMM-uuuu HH:mm:ss.SSS';
类别
在 帮助中心 和 File Exchange 中查找有关 Holidays / Seasons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!