Matfile modify the variable of a structure
Afficher commentaires plus anciens
Hello all
I need advices on how to use matfile().
I have a .mat file which is a structure. This file is called '2019hydro.mat' and is a structure subdivided into 9 330x300x365 matrices.
When I load the file I have the structure 'global_structure' subdivided into the 9 matrices ('smb', 'albedo', 'abl' etc...)
Everyday there are 9 330x300 matrix that I calculate to iterate in this global_structure depending on the day. Let's say we are the 31st of December, for the variable 'smb' I will write :
global_structure.smb(:, :, 365) = calculated_smb;
Because this structure is really heavy, I was advised to use matfile().
To test my code, I wrote :
m = matfile('2019hydro.mat', 'Writable', true)
And normally to iterate the calculated matrices I would write:
m.global_structure.smb(:, :, 365) = calculated_smb;
But I get an error message saying "Cannot index into 'global_structure' because MatFile objects only support '()' indexing." .
However when I open 'm' in the workspace I have 2 structures: 'properties', and 'global_structure' which has my 9 330x300x365 matrices.
Why can I see the matrices in my 'global_structure' by clicking on it from the workspace, but I can't access it from the command window by typing 'm.global_structure.smb' ? I also tried doing an imagesc to display the data on a specific day (eg: imagesc(m.global_structure.smb(:, :, 364) ) but I have the same error message.
How can I get rid of this issue ?
Thanks for your help !
ps: I can't upload the file because of its size, I hope I was clear enough. In case I wasn't, I will explain my issue again more clearly.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur App Building dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!