Is their any way to load only selected fields from a saved structure array.
조회 수: 51(최근 30일)
Stephen23 2017년 2월 15일
편집: Stephen23 2017년 2월 15일
Make sure you save the structure array using the '-struct' option:
And then, exactly as the load documentation says, you can load the variables by supplying their names as optional arguments. E.g. if the mat file contains variables X and Y:
S = load(filename,'X','Y');
This will only load X and Y into the structure S, not matter what other variables are also present in the mat file.
>> S.X = 1:3;
>> S.Y = 4:5;
>> S.Z = 6:9;
>> S = load('test.mat','X','Y');
Walter Roberson 2017년 2월 15일
Sorry there is no Mathworks provided way to do that.
If you just happen to be using a v7.3 mat file then I wonder if there would be an approach by using hdf5 routines to access the mat file?