📄 sptest.m
字号:
E=[4,1,0,0,0,0,0,0,0,0,0;1,4,1,0,0,0,0,0,0,0,0;0,1,4,1,0,0,0,0,0,0,0;
0,0,1,4,1,0,0,0,0,0,0;0,0,0,1,4,1,0,0,0,0,0;0,0,0,0,1,4,1,0,0,0,0;
0,0,0,0,0,1,4,1,0,0,0;0,0,0,0,0,0,1,4,1,0,0;0,0,0,0,0,0,0,1,4,1,0;
0,0,0,0,0,0,0,0,1,4,1;0,0,0,0,0,0,0,0,0,1,4];
F=E/6;
K=inv(F);
x = 0:10; y = sin(x);
format long
A=K*y'
a1=[0,A',0,0]
coefM=[-1,3,-3,1;3,-6,3,0;-3,0,3,0;1,4,1,0];
b=zeros(1,4);
b=b';tt=a1'
out=[];
for k=1:length(y)-1
out=[out,y(k)];
for p=1:3
ptt=[(p*1/4)^3,(p*1/4)^2,p*1/4,1];
b=coefM*tt(k:k+3);
out=[out,b'*ptt'/6];
end
end
out=[out,y(length(y))]
xi = 0:.25:10;
%yi = spline(x,y,xi);
%plot(x,y,'o',xi,yi);
%figure(2);
plot(x,y,'o',xi,out);
errorga=max(abs(out-sin(xi)))
%errorsp=max(abs(yi-sin(xi)))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -