www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/WriteTabletoTextFileExample.m

    %% Write Table to Text File  

% Copyright 2015 The MathWorks, Inc.


%% 
% Create a table. 
T = table(['M';'F';'M'],[45 45;41 32;40 34],...
    {'NY';'CA';'MA'},[true;false;false])  

%% 
% Write the table to a comma delimited text file and display the file contents. 
writetable(T) 

%%
% |writetable| outputs a text file named |T.txt|.  

%% 
type 'T.txt' 

%%
% |writetable| appends a unique suffix to the variable name, |Var2|, above
% the two columns of corresponding data.