datastore and .mat files

30 次查看(过去 30 天)
minomi
minomi 2018-7-31
回答: Harsh 2018-8-1
I have a few .mat files containing a table of variables. I tried using datastore for the files so that then I can create timetables and apply timerange to select the rows of data within the specificed time. my scripts looks like this:
warning off
ds_loc = 'Z:\Desktop\*.mat';
ds = datastore(ds_loc);
ds.Delimiter = ' ';
ds.MultipleDelimitersAsOne = 1;
ds.SelectedFormats(1) = {'%{dd/MM/yyyy HH:mm:ss}D'};
warning on
tt = tall(ds);
ttab = table2timetable(tt)
strt_time = '03/12/2018 10:00:00'
end_time = '03/13/2018 00:00:00'
warning off
S1 = timerange(strt_time,end_time);
warning on
S2 = ttab(S1,:)
this script works fine with .txt files but with .mat files I get the error:
Error using datastore (line 114)
Cannot determine the datastore type for the specified location.
Specify the 'Type' name-value pair argument to indicate the type of datastore to create.
Error in cls_test (line 10)
ds = datastore(ds_loc);
Please could someone advise on what I'm doing wrong?

回答(1 个)

Harsh
Harsh 2018-8-1
You can use fileDatastore for .mat files. An example of this can be found in the doc here .

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by