www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/WriteandAppendDatatoFileExample.m
%% Write and Append Data to File %% % Create two arrays of sample numeric data. M = magic(5); N = magic(3); %% % Export matrix |M| to a file and use whitespace as the delimiter. dlmwrite('myFile.txt',M,'delimiter',' '); %% % Append matrix |N| to the file, offset from the existing data by one row. % Then, view the file. dlmwrite('myFile.txt',N,'-append',... 'delimiter',' ','roffset',1) type('myFile.txt') %% % Read the data in |'myFile.txt'| using |dlmread|. dlmread('myFile.txt') %% % When |dlmread| reads the two matrices from the file, it pads the smaller % matrix with zeros.