sv.m

来自「用matlab实现利用统计混沌方法解决非线性系统时间序列预测的问题」· M 代码 · 共 42 行

M
42
字号
function sv(in,filename)
% The function: 
%
%       sv(in,filename)
%
% saves the variable <in> in the file <filename>.
%
% The optional string <filename> contains the name (and the path) 
% of a file to be written in the .dat format.
% If <filename> is not specified, a dialog box is displayed. 
%
% See also ld

if nargin<1,
        disp('you must specify a variable in arg1');
        return;
end;
if nargin<2,
        [filename,filepath] = uiputfile('*.dat','sv: Save File As ...');
        if filename==0, 
                return;
        else,
                filename = strcat(filepath,filename);
        end;
end;

[row,col] = size(in);

fid=fopen(filename,'wt');
if fid>=0,
        fprintf(fid,'%e\t',col);
        fprintf(fid,'%e\t',zeros([1,col-1]));
        fprintf(fid,'\n');
        fprintf(fid,'%e\t',row);
        fprintf(fid,'%e\t',zeros([1,col-1]));
        fprintf(fid,'\n');
        for i=1:row,
                fprintf(fid,'%e\t',in(i,:));
                fprintf(fid,'\n');
        end;
        fclose(fid);
end;        

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?