📄 fappend.m
字号:
function theResult = fappend(varargin)% fappend -- Append files to an existing file.% fappend('outfile', 'infile_1', infile_2', ...)% appends the given input files to the output% file, creating it if necessary. Partial names% are resolved with the Matlab "which" command.% Note: the output file should not have the same% name as any input file. % Copyright (C) 2001 Dr. Charles R. Denham, ZYDECO.% All Rights Reserved.% Disclosure without explicit written consent from the% copyright owner does not constitute publication. % Version of 06-Aug-2001 14:18:38.% Updated 06-Aug-2001 14:55:12.CHUNK = 2048;if nargin < 1 help(mfilename) returnendw = which(varargin{1});if ~isempty(w) outfile = w;else outfile = varargin{1}; fout = fopen(outfile, 'a'); if fout < 0 disp([' ## Unable to create/open output-file: "' outfile '"']) return end outfile = fopen(fout); fclose(fout);endfor i = 2:length(varargin) infile = which(varargin{i}); if isequal(outfile, infile) disp(' ## Output-file must not have the same name as any input-file.') return elseif isempty(infile) disp([' ## No such input-file: "' varargin{i} '"']) return endendfout = fopen(outfile, 'a');if fout < 0 disp([' ## Unable to open output-file: "' outfile '"']) returnendfor i = 2:length(varargin) infile = which(varargin{i}); fin = fopen(infile, 'r'); if fin < 0 disp([' ## Unable to open output-file: "' infile '"']) fclose(fout) return end while (1) [s, count] = fread(fin, [1 CHUNK]); % Read characters. if count > 0 fwrite(fout, s); end if count < CHUNK fclose(fin); break; end endendfclose(fout);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -