How can I load a field from a struct that is stored within a .mat file?

20 views (last 30 days)
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,

Accepted Answer

Walter Roberson
Walter Roberson on 26 May 2023
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.

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!