splint2.m

来自「用matlab写的一些数值算法」· M 代码 · 共 17 行

M
17
字号
function  s = splint2(x,p,t)
% Compute values of cubic spline with knots x and coefficients
% p, see SPLINT1.

% Version 11.12.2003.  INCBOX

if  any((t < x(1)) | (t > x(end)))
  error('arguments must be in knot range')
end
s = zeros(size(t));               % vector of same type as  t
for  i = 1 : length(x)-1          % run through knot intervals
  k = find((x(i) <= t) & (t <= x(i+1)));
  if  ~isempty(k)                      % arguments in interval
    u = (t(k) - x(i))/(x(i+1) - x(i));  % Normalized arguments
    s(k) = p(i,1) + u.*(p(i,2) + u.*(p(i,3) + u*p(i,4)));
  end
end

⌨️ 快捷键说明

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