码迷,mamicode.com
首页 > 其他好文 > 详细

Matlab piecelin

时间:2017-06-12 14:50:23      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:nes   pac   ack   val   return   interval   rpo   article   with   

function v = piecelin(x,y,u)
%PIECELIN  Piecewise linear interpolation.
%  v = piecelin(x,y,u) finds the piecewise linear L(x)
%  with L(x(j)) = y(j) and returns v(k) = L(u(k)).

%  First divided difference

   delta = diff(y)./diff(x);

%  Find subinterval indices k so that x(k) <= u < x(k+1)

   n = length(x);
   k = ones(size(u));
   for j = 2:n-1
      k(x(j) <= u) = j;
   end

%  Evaluate interpolant

   s = u - x(k);
   v = y(k) + s.*delta(k);

Matlab piecelin

标签:nes   pac   ack   val   return   interval   rpo   article   with   

原文地址:http://www.cnblogs.com/gavanwanggw/p/6992491.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!