Working with fileDatastore and loading its data
Mostrar comentarios más antiguos
Hi,
I have a large files in Current file which I need to work with. These files are named D2_boneName.mat and contains doubles in only one row.
I would like to load each file and find the minimal and maximal number from each and finally count the histogram.
My script is this and the error is "Unable to use a value of type 'struct' as an index. Error in vypocti_cetnosti (line 10) maxK(i) = max(kost);"
Can you help me, how to rewrite it to work correctly?
fds = fileDatastore('D2_*.mat','ReadFcn',@load);
i = 1;
min=0;
max=0;
while hasdata(fds)
[kost,info] = read(fds);
maxK(i) = max(kost);
minK(i) = min(kost);
i = i+1;
end
dilek = (max(maxK)-min(minK))/50;
deleni = min(minK):dilek:max(maxK);
i=1;
while hasdata(fds)
[T_A,info] = read(fds);
kost = T_A{:,:};
[cetnostiObjemu,krajeObjemu]=histcounts(kost,deleni);
cetnostiObjemu=cetnostiObjemu/size(kost,2);
[~,fname] = fileparts(info.Filename);
save(['cetnosti_' fname], 'cetnostiObsahu')
i = i+1;
end
Respuestas (1)
Cris LaPierre
el 26 de Sept. de 2020
Editada: Cris LaPierre
el 26 de Sept. de 2020
What is the name of the variable you are loading? That is a fieldname in the structure kost. You access it using dot notation:
max(kost.Var)
Categorías
Más información sobre Genomics and Next Generation Sequencing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!