linint.m

来自「非线性控制 Matlab编译」· M 代码 · 共 47 行

M
47
字号
function u=linint(in,out,p,n);% U=LININT(IN,OUT,P,N)% Highdimensional linear interpolator for possibly nonlinear data sets.% IN is a vector of reference points of Nxm.% OUT is a vector of corresponding outputs Nxn% P is ia vector in a reference (input) space Mxm% N is the number of nearest neighbors to use in interpolation% NONL returns an Mxn vector linearly interpolated in the output space% Procedure: Sort points in IN space by their distance to P % and find 2*m nearest points to make a linear interpolation by SVD% Valery Petrov,% CNLD 10-06-96% Copyright (c) 1996-1998 The University of Texas at Austin  dim=size(p,1);  sz=size(p,2);if (size(in,2)<n) Length=size(in,2) Neighbors=n error('Not enough points in the input vector!');endif (dim>=n) Dim=dim Neighbors=n error('Not enough neighbors specified!');end  for i=1:sz   [r,ri]=sort(dist2(p(:,i)',in));   ind=ri(1:n);    RHS=in(:,ind)';%Subtract mean    mRHS=mean(RHS);    RHS = RHS-(ones(size(RHS,1),1)*mRHS);    LHS=(p(:,i)'-mRHS);%Condition each column by the fluctuation amplitude    sRHS=std(RHS);    RHS = RHS./(ones(size(RHS,1),1)*sRHS);    LHS=LHS./(ones(size(LHS,1),1)*sRHS);    u(:,i)=(out(:,ind)/[RHS'; ones(size(ind))])*[LHS'; 1];  end

⌨️ 快捷键说明

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