《三次样条插值(2页).doc》由会员分享,可在线阅读,更多相关《三次样条插值(2页).doc(2页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、-三次样条插值2010-05-28 10:14function varargout=saxplaxliu(varargin)clear,clcx=0.25 0.3 0.39 0.45 0.53;y=0.5 0.5477 0.6254 0.6708 0.728;fd=1 0.6868;x0=0.4;yx0=splineL(x,y,fd,x0)function yx0=splineL(x,y,fd,x0)%x=x0 x1 xn%y=y0 y1 yn%fd=df0 dfn;%n=length(x)-1;f=x;h=x;m=x;for i=1:nh(i)=x(i+1)-x(i);f(i)=(y(i+1
2、)-y(i)/h(i);endB=2*ones(1,n-1);m(1)=fd(1);m(end)=fd(2);A=B;C=B;g=A;for i=1:n-1C(i)=h(i)/(h(i+1)+h(i);A(i)=h(i+1)/(h(i+1)+h(i);g(i)=3*(A(i)*f(i)+C(i)*f(i+1);endfL(1)=g(1)-A(1)*fd(1);fL(n-1)=g(n-1)-C(n-1)*fd(2);fL(2:n-2)=g(2:n-2);m(2:n)=zgf(A,B,C,fL);yx0=fliu(x,y,m,x0);function y=fliu(xj,yj,mj,x)n=len
3、gth(xj);y=0;for i=1:ns=1;for j=1:nif i=js=s*(x-xj(j)/(xj(i)-xj(j);endendbi=(x-xj(i)*s2;s1=0;for j=1:nif i=js1=s1+1/(xj(i)-xj(j);endendy=y+yj(i)*(1-2*(x-xj(i)*s1)*s2+mj(i)*bi;endfunction x=zgf(A,B,C,f)%解 b1 c1% a2 b2 c2% . . . *x=f% % an bnn=length(B);B1=zeros(1,n-1);Y=zeros(1,n);x1=zeros(1,n);B1(1)=C(1)/B(1);for i=2:n-1B1(i)=C(i)/(B(i)-A(i)*B1(i-1);endY(1)=f(1)/B(1);for i=2:nY(i)=(f(i)-A(i)*Y(i-1)/(B(i)-A(i)*B1(i-1);endx1(n)=Y(n);for i=n-1:-1:1x1(i)=Y(i)-B1(i)*x1(i+1); endx=x1;-第 2 页-