How can I load a field from a struct that is stored within a .mat file?
39 views (last 30 days)
Show older comments
Hello, I am hoping someone here could help me with figuring out how to save a part of a struct that I have. Basically, this struct originates from data loaded into matlab through an extension (Delft3D Quickplot). This struct, called 'data' is savable within a .mat file, but I actually only need 3 variables: Val, X and Y. I need this since I want to get time series of water depths (which is what the val or value refers to) for specific coordinates. I have tried loading only a variable in ways such as: b = load('matlab.mat', 'Val') or using var = load( fullfile('D:\ directory path', 'matlab.Mat'), 'Val' ); but these options do not seem to work. I would really appreciate the help and suggestions.
Kind regards,
0 Comments
Accepted Answer
Walter Roberson
on 26 May 2023
In the case that the .mat file was saved with -v7.3 then see https://www.mathworks.com/help/matlab/import_export/load-parts-of-variables-from-mat-files.html
If the .mat file was saved with -v7 (the default for most people) then the operations will be permitted but will still require loading the entire variable into memory and so will not have the hoped-for efficiency.
0 Comments
More Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!