Relevant code:
function result = loadStructFromFile(fileName, environmentName)
result = load(fileName, environmentName);
bigMatrix = loadStructFromFile('values.mat','bigMatrix');
But when I look in the workspace, it shows 'bigMatrix' as a 1x1 struct. When I click on the struct, however, it is the actual data (in this case a a 998x294 matrix).
As the documentation of LOAD indicates, if you call it with an output argument, the result is returned in a struct. If you do not call it with an output argument, the variables are created in the local workspace with the name as which they were saved.
For your function loadStructFromFile
, if the saved variable name can have different names (I assume environmentName
), you can return the variable by writing
function result = loadStructFromFile(fileName, environmentName)
tmp = load(fileName, environmentName);
result = tmp.(environmentName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With