www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/LoadandSavePartsofVariablesExample.m
%% Load and Save Parts of Variables % Access specific elements of a MAT-file variable. %% % Open a new MAT-file, |myFile2.mat|. m = matfile('myFile2.mat'); %% % Save a 20-by-20 example array to part of a variable, |y|, in |myFile2.mat|. % Specify the variable in the MAT-file using dot notation similar to accessing % fields of structure arrays. m.y(81:100,81:100) = magic(20); %% % MATLAB(R) inserts the 20-by-20 array into the elements of |y| specified % by the indices |(81:100,81:100)|. %% % Read a subset of array |y| into a new workspace variable, |z|. z = m.y(85:94,85:94); %% % MATLAB reads the 10-by-10 subarray specified by the indices |(85:94,85:94)| % from the MAT-file into workspace variable |z|.