I have a struct (of matrices) in Matlab that has been saved on the harddisk. I currently use load to load these files inside my functions. Do you have any suggestions of doing this someother way that is much faster?
(Yes, I can pass the struct as a variable to my function but that is not possible due to memory issues!). Thanks! This would be a great help!
A = struct('local', randn(200000,14), 'usd', randn(200000,14), ...
'ttm', randn(180000,14), 'avg', randn(190000,14), ...
'ttm1yr', randn(190000,14), 'avg1yr', randn(190000,14)) ;
save('A.mat', 'A') ; clear all;clc
tic, load A.mat, A=A.local; toc %--> Takes 1.05 seconds
It appears that you’re interested only in specific chunks of your saved file. I would suggest changing the format of the saved data so that individual variables can be loaded using the
form of
load. This will speed up the loading significantly, since you’ll avoid copying all of the unwanted data from disk into memory, just to free it right away.If your data is already in struct form, you can use this form of
save(from the online docs):