补充下列matlab程序 用函数lsqcurvefit拟合y=c*(1-e^(-d*x))中的参数c d。 1)编写M-文件 curvefun
已帮助 人
补充下列matlab程序,用函数lsqcurvefit拟合y=c*(1-e^(-d*x))中的参数c,d。 1)编写M-文件 curvefun2.m function f=curvefun2(a,xdata) f=(); %其中a(1)=c, a(2)=d 2)输入命令 xdata=[3 4 5 7 9 15]; ydata=[1 2 4 6 8 10]; a0=[1 1]; a=lsqcurvefit ("curvefun2",a0,xdata,ydata); f= curvefun2(a,tdata);

回答
共1条回复-
clear;close;
x=-2:0.1:2;y=x;
[x,y]=meshgrid(x,y);
a=0.5457;b=0.7575;
p=a*exp(-0.75*y.^2-3.75*x.^2-1.5*x).*(x+y>1);
p=p+b*exp(-y.^2-6*x.^2).*(x+y>-1).*(x+y<=1);
p=p+a*exp(-0.75*y.^2-3.75*x.^2+1.5*x).*(x+y<=-1);
mesh(x,y,p)
