Reading uneven datasets from .mat file
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello all,
I'm trying to load datasets from .mat file in MATLAB. However, my datasets are not evenly distributed due to which I cannot import my entire dataset into MATLAB. My datasets are spilt in the intervals of 20 and 21. Is there a way to import the entire datasets at once into MATLAB?Please provide some suggestions to resolve this issue.
Thanks in advance!
3 comentarios
Stephen23
el 11 de Mayo de 2023
Editada: Stephen23
el 11 de Mayo de 2023
Rather than generating the fieldnames youself (including non-existent ones), why not just loop over the existing fieldnames?:
If the aim is simply to extract to a numeric matrix, you could use STRUCT2CELL and then CAT(3,..).
Or STRUCTFUN with a function that returns a scalar cell, then again CAT(3,...).
Respuestas (1)
Stephen23
el 11 de Mayo de 2023
Editada: Stephen23
el 11 de Mayo de 2023
Assuming that:
- the fields are in the required order (otherwise: you can sort them using ORDERFIELDS).
- the MAT file contains only the data that you require (otherwise: you can specify the variables to import).
S = load('testcase.mat');
C = structfun(@(m){m},S);
A = cat(3,C{:})
4 comentarios
Stephen23
el 11 de Mayo de 2023
"But can I load all frames at once? I only need frames (frame21 to frame 30215), will it be possible to import everything at once?"
The LOAD command i gave you in my last comment will import every variable whose name is "Frame" followed by some digits. That seems to match exactly what you describe. Did you try it? Did it not work for you?
Ver también
Categorías
Más información sobre Large Files and Big Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!