| 查看: 813 | 回复: 5 | |||
[交流]
【求助】急求帮忙解决MATLAB 样条差值求解微分代码出现的问题,使代码正常运行
|
|
function y0=hillsplines3(x0,x,y) if size(x,1)~=1 x=x'; end if size(y,1)~=1 y=y'; end [a,t]=hillsplinex(x,y);a=a';t=t'; for i=1:length(t)-4 phi(i)=powerplus3(x0,t(i:i+4)); end y0=sum(a.*phi); function [ax,tx]=hillsplinex(t,y) h=diff(t);delta=diff(y)./h;n=length(h)+1 d1=pchipendpoint(h(1),h(2),delta(1),delta(2)); dn=pchipendpoint(h(n-1),h(n-2),delta(n-1),delta(n-2)); r=[d1;y';dn]; tx=[t(1)-[1:3]*h(1),t,t(length(t)+[1:3])*h(length(h))]; a=zeros(length(tx)-4,length(tx)-4); for i=1:3 a(1,i)=depowerplus3(t(1),tx(i:i+4)); end for i=length(tx)-6:length(tx)-4 a(length(tx)-4,i)=depowerplus3(t(length(t)),tx(i:i+4)); end for j=2:length(tx)-5 for i=j-1:j+1 a(j,i)=powerplus3(t(j-1),tx(i:i+4)); end end ax=a\r;tx=tx'; function y=powerplus3(x,t) c=t; for i=1:5 c(i)=[]; beta(i)=24/prod(t(i)-c); c=t; end powerplus=abs(x-t).^3; y=0.5*sum(beta.*powerplus); function y=depowerplus3(x,t) c=t; for i=1:5 c(i)=[]; beta(i)=24/prod(t(i)-c); c=t; end powerplus=3*sign(x-t).*(x-t).^2; y=0.5*sum(beta.*powerplus); function d=pchipendpoint(h1,h2,del1,del2) d=((2*h1+h2)*del1-h1*del2)/(h1+h2); if sign(d)~=sign(del1) d=0; elseif(sign(del1)~=sign(del2))&(abs(d)>abs(3*del1)) d=3*del1; end [ Last edited by huameitang05 on 2011-1-4 at 17:21 ] |
» 猜你喜欢
梦想
已经有8人回复
有多少人是今天查系统知道结果的?
已经有19人回复
面上合作单位盖章
已经有9人回复
面上函评意见出来了,像什么等级?
已经有17人回复
为什么国自然不能直接公布
已经有5人回复
学科评审组评审是指会评吗?
已经有4人回复
为什么资助数各大高校都创新高,自己申请怎么就这么难
已经有14人回复
小白求助 投论文要求的highlights应该如何写
已经有4人回复
麻烦专家们看看评委们的意见(F口面上)
已经有12人回复
怎么看青基中了没有啊
已经有6人回复
2楼2011-01-04 19:06:32
3楼2011-01-04 19:31:42
4楼2011-01-04 19:47:16
5楼2011-01-04 19:49:24
6楼2011-02-28 21:36:36










回复此楼

30