Effacer les filtres
Effacer les filtres

datastore and .mat files

40 vues (au cours des 30 derniers jours)
minomi
minomi le 31 Juil 2018
Réponse apportée : Harsh le 1 Août 2018
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?

Réponses (1)

Harsh
Harsh le 1 Août 2018
You can use fileDatastore for .mat files. An example of this can be found in the doc here .

Community Treasure Hunt

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

Start Hunting!

Translated by