areadr3.m

来自「PLS_Toolbox是用于故障检测与诊断方面的matlab工具箱」· M 代码 · 共 42 行

M
42
字号
function [out,line] = areadr3(file,nline,nrow);
%AREADR3 reads ascii text and converts to a data matrix
%  Input is (file) an ascii string containing the file name
%  to be read, (nline) the number of rows to skip before reading
%  and (nrow) the number of rows common to the input data and
%  the output data matrix (out).
%
%Warning: conversion may not be successful for files from
%  other platforms
%
%I/O: out = areadr3(file,nline,nrow);
%
%See also: AREADR1, AREADR2, AREADR4

%Copyright Eigenvector Research, Inc. 1996-98

[fid,message] = fopen(file,'r');
if fid<0
  disp(message)
else
  for i=1:nline
    line     = fgets(fid);
  end
  [a,count]  = fscanf(fid,'%g',[inf]);
  [na,ma]    = size(a);
  no         = na/nrow;
  if (no-floor(no))~=0
  s = ['Error-Number of columns nvar does'];
  s = [s,' not appear to be correct for file ',file];
  error(s)
  elseif count<1
    disp('Conversion does not appear to be successful')
  else
    for i=1:nrow
      jj       = (i-1)*no;
      j        = [jj+1:jj+no];
      out(i,:) = a(j,1)';
    end
  end
end
fclose(fid);

⌨️ 快捷键说明

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