ratcof.m

来自「matlab高级统计工具箱」· M 代码 · 共 24 行

M
24
字号
function [a,b]=ratcof(xdata,ydata,ntop,nbot)
% [a,b]=ratcof(xdata,ydata,ntop,nbot)
% Determine a and b to approximate ydata as a rational
% function of the variable xdata. The function has the form:
%
%      y(x) = sum(1=>ntop)( a(j)*x^(j-1) ) /
%	   ( 1 + sum(1=>nbot)( b(j)*x^(j)) )
%
%   xdata,ydata     input data vectors (real or complex)
%   ntop,nbot       number of series terms used in the
%                   numerator and the denominator.
%		    If nbot not entered nbot=ntop unstable for large ntop>10
%
%     Use RATERP to calc y(x)

%	     H.B.Wilson, Oct 1988-Modified A.Jutan-Jan 90

ydata=ydata(:);  xdata=xdata(:); m=length(ydata);
if nargin==3, nbot=ntop; end;
x=ones(m,ntop+nbot);  x(:,ntop+1)=-ydata.*xdata;
for i=2:ntop, x(:,i)=xdata.*x(:,i-1); end
for i=2:nbot, x(:,i+ntop)=xdata.*x(:,i+ntop-1); end
ab=x\ydata; a=ab(1:ntop); b=ab(ntop+1:ntop+nbot);

⌨️ 快捷键说明

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