MATLAB: How to save a property of a struct without copying it to a variable

MATLAB

The 'save' function takes variable names as strings, but if I have a structure, I cannot save an individual property without first saving it to a variable (or without saving all properties of the struct). Is there a way to save just an individual property?

Best Answer

You could use the "matfile" function.  Please refer to the following link for examples on how to save and load part of a variable: <http://www.mathworks.com/help/matlab/ref/matfile.html#bt19yqz-1>
Please try the following example:
 
test = struct('a', [1 2 3],'b',[4 5 6])
m = matfile('myMatfile.mat');
m.a = test.a
From here, you can clear your variables using 'clear' and load 'myMatfile.mat', which should load the variable 'a' back into the workspace.