我可以在Scilab中执行类似 this 的操作吗?通过fsolve(...)?
我认为有必要添加一些东西来改善这个问题。
我有一个定义如下的函数:
function f=equ(x)
f=y-((-0.0235037+39.432867*x)/(1+83.598972*x-43.946883*x.^2));
endfunction
然后这个:
i=1;
xp(1)=xD;
yp(1)=xD;
y=xD;
while (xp(i)>xi),
xp(i+1)=fsolve(0.01,equ);
yp(i+1)=R/(R+1)*xp(i+1)+xD/(R+1);
y=yp(i+1);
plot([xp(i),xp(i+1)],[yp(i),yp(i)],"r");
if (xp(i+1)>xi) plot([xp(i+1),xp(i+1)],[yp(i),yp(i+1)],"r");
end
i=i+1;
end
我想用样条拟合改变函数:
xx=linspace(0,1,100)';
yy2=interp1(x,y,xx,"spline");
其中x,y是实验数据(x = [...],y = [...]),或者:
xx=linspace(0,1,100)';
df=splin(x,y,"monotone");
[yyf,yy1f,yy2f]=interp(xx,x,y,df);
我可以将fsolve应用于样条拟合吗?或者做其他事情是必要的吗?感谢。
答案 0 :(得分:0)
像this之类的东西?使用splin?
x = [2,3,4,5,6];
y = [10,8,4,1,-2];
xi = linspace(2,6,100);
yk = interp(xi, x, y, splin(x,y,"not_a_knot"));
yf = interp(xi, x, y, splin(x,y,"fast"));
ym = interp(xi, x, y, splin(x,y,"monotone"));
plot(x,y,'o',xi,yk,'-')
plot(x,y,'X',xi,yf,'-r')
plot(x,y,'+',xi,yf,'-b')
xlabel('x')
ylabel('y')
legend(['','Not a knot','','Fast','','Monotone'])