MATLAB--第四次实验.docVIP

  • 36
  • 0
  • 约2.82千字
  • 约 12页
  • 2018-01-08 发布于江西
  • 举报
MATLAB--第四次实验.doc

评分 实验报告 二、实验环境: 1、硬件配置:电脑一台 (Windows7 64位操作系统) 2、软件环境:安装MATLABR2012 a软件 三、实验内容: 例1 求解范德蒙方程y1”-u(1-y1^2)y1’+y1=0,其中令u等于1。首先将重写为一阶方程的形式。记y2=y1’,则上述方程式写为:y2’=u(1-y1^2)y2-y1. 4-1 有如下数据: X [1 1.1 1.2 1.3 1.4] Y [1.0000 1.23368 1.55271 1.99372 2.61179] 利用本章介绍的几种插值方法对其进行插值,得到每隔0.05的结果。 4-2 求下列函数的数值,并绘制图形。 (1)y=e^x-x^5,初始值为x=8. (2)y=xsinx. 4-3 求下列函数的极值。 (1)z=x^2-(y-1)^2. (2)z=(x-y+1)^2. 4-4 计算下列积分: (1) ∫-11x-x3+x5dx. (2)∫101∫101siny[(x+y)/(x2+4)]dxdy. 四、实验结果与分析: 例1 [t,y]=ode45(@vdp1,[0 20],[2;0]); plot(t,y(:,1),-,t,y(:,2),--) title(Solution of van der Pol Equation,\mu=1); xlabel(time t); ylabel(solution y); legend(y_1,y_2); 4-1 x=[1 1.1 1.2 1.3 1.4] y=[1.00000 1.23368 1.55271 1.99372 2.61170] length_of_x=length(x); scalar_x=[x(1):0.05:x(length_of_x)]; length_of_sx=length(scalar_x) for i=1:length_of_sx y_nearest(i)=interp1(x,y,scalar_x(i),nearest); y_linear(i)=interp1(x,y,scalar_x(i),linear); y_spline(i)=interp1(x,y,scalar_x(i),spline); y_cubic(i)=interp1(x,y,scalar_x(i),cubic); end subplot(2,2,1),plot(x,y,*),hold on,plot(scalar_x,y_nearest),title(method=nearest); subplot(2,2,2),plot(x,y,*),hold on,plot(scalar_x,y_linear),title(method=linear); subplot(2,2,3),plot(x,y,*),hold on,plot(scalar_x,y_spline),title(method=spline); subplot(2,2,4),plot(x,y,*),hold on,plot(scalar_x,y_cubic),title(method=cubic); 4-2 (1)y=@(x)exp(x)-x^5; x=fzero(y,8) fplot(y,[x-1,x+1]); hold on plot(x,y(x),r*) x =12.7132 (2) y=@(x)x*sin(x); x=fzero(y,0) fplot(y,[x-1,x+1]); hold on plot(x,y(x),r*) x = 0 4-3 (1) z=@(x)x(1)^2-(x(2)-1)^2; [x,fvalue,flag,output]=fminsearch(z,[0,0]) Exiting: Maximum number of function evaluations has been exceeded - increase MaxFunEvals option. Current function value: -359212266339440800000000000000000000000000000000000000000000000000000000000000000000.000000 x = 1.0e+041 * 0.9523 -6.0686 fvalue =-3.5921e+083 flag

文档评论(0)

1亿VIP精品文档

相关文档