ld.m

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

M
41
字号
function [out,row,col] = ld(filename)
% The function: 
%
%       [out,row,col] = ld(filename)
%
% loads the file <filename> in the variable <out>.
%
% The optional string <filename> contains the name (and the path) 
% of a file written in the .dat format.
% If <filename> is not specified, a dialog box is displayed. 
%
% <row> and <col> are such that [row,col] = size(out)
%
% See also sv

if nargin<1,
        [filename,filepath] = uigetfile('*.dat','ld: Load File');
        if filename==0, 
                out = [];
                row = 0;
                col = 0;
                return;
        else,
                filename = strcat(filepath,filename);                
        end;
end;

fid=fopen(filename,'rt');
if fid>=0,
        col = fscanf(fid,'%e',[1,1]);
        fscanf(fid,'%e',[1,col-1]);
        row = fscanf(fid,'%e',[1,1]);
        fscanf(fid,'%e',[1,col-1]);
        out = fscanf(fid,'%e',[col,row])';
        fclose(fid);
else,
        disp(strcat('file <',filename,'> not found!'));
        out = 0;
        row = 0;
        col = 0;
end;        

⌨️ 快捷键说明

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