www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@localtruncps/eval.m
function y= eval(ts,x) % LOCALTRUNCPS/EVAL % Copyright 2000-2013 The MathWorks, Inc. and Ford Global Technologies, Inc. beta=double(ts.xreglinear); y = polyval_mex(beta(1:ts.order),x); m = ts.order-1; for i=1:length(ts.knots); rhs = x>ts.knots(i); y(rhs) = y(rhs) + beta(m+i+1)*(x(rhs)-ts.knots(i)).^m; end %{ % below is a Matlab code version of the polyval_mex mex file function y = polyval(p,x) plen = length(p); xlen = length(x); % Start the polynomial at the beginning for each x value y = ones(xlen, 1)*p(1); if plen>0 % loop over the length of the x vector for xi=1:xlen % loop over the size of the polynomial for pi=2:plen y(xi) = p(pi) + y(xi)*x(xi); end end end %}