📄 wr_columns.m
字号:
function wr_columns(filename,data,text,format)% Function writes array to ASCII file%% Written by: E. R.:% Last updated: May 5, 2005: filename without path triggers file selection box% % wr_columns(filename,data,text,format)%% INPUT% filename name of file to create (if empty, file will be interactively selected)% data data to store in columnar format% text cell array with ASCII text to be placed in front of data% If "text" is empty but global variable S4M is not empty% then the string ['Created by ',S4M.script] will be printed on % the first line% format optional string with format for coversion of numeric data% Default: '%10.6g' global S4M ABORTEDABORTED=logical(1);% Open the filefid=open_textfile4writing(filename);if fid < 0 returnend% Write text above dataif nargin > 2 if isempty(text) if ~isempty(S4M) fprintf(fid,['Created by ',S4M.script,'\n']); end else if ~iscell(text) fprintf(fid,[strrep(text,'\','\\'),'\n']); else for ii=1:length(text) fprintf(fid,[strrep(text{ii},'\','\\'),'\n']); end end endend% Write data[n,m]=size(data);if nargin > 3 format=['%s',format];else format=' %s %10.6g';endfor ii=1:n if mod(ii,10000) == 0 fprintf('%d of %d lines of data written.\n',ii,n); end for jj=1:m fprintf(fid,format,' ',data(ii,jj)); end fprintf(fid,'\n'); endfclose(fid);ABORTED=logical(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -