No BSD License  

Highlights from
nlcontrol

nlcontrol

by

 

Nonlinear algorithm for controlling dynamical systems, particularly where linear methods fail.

u=linint(in,out,p,n);
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!');
end

if (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

Contact us