www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SaveEntireVariabletoExistingMATfileExample.m
%% Save Entire Variable to Existing MAT-file %% % Generate a 20-by-20 example array, |x|, and save it to a MAT-file called % |myFile.mat|. x = magic(20); save('myFile.mat','x'); %% % Create a MAT-file object connected to the existing MAT-file named |myFile.mat|. % Enable write access to the MAT-file by setting |Writable| to |true|. m = matfile('myFile.mat','Writable',true); %% % Generate a 15-by-15 example array, |y|. y = magic(15); %% % Save |y| to the MAT-file. Specify the variable in the MAT-file using dot % notation similar to accessing fields of structure arrays. m.y = y; %% % MATLAB(R) adds a variable named |y| to the file. %% % Display all variables stored in the MAT-file, |myFile.mat|. whos('-file','myFile.mat')