- 3
- 0
- 约3.55千字
- 约 9页
- 2017-02-16 发布于湖北
- 举报
数学物理建模与计算机仿真考试试题
(2014——2015第一学期)
计算机仿真计算积分: (n为自然数)
积分方向为正方向(10分)。
解:
clear all
%利用留数定理求解有方向的闭合路径的积分计算
m zeros 1,101 ;
m 1 1;
m 101 1; [R,P,K] residue [1 0],m ;
int 2*pi*sum R
在同一幅图中绘制函数 (不要投影图)和平面 的图像(10分)。
解:
程序:
function text2
clear all
z 2*cplxgrid 30 ;
cplxmap1 z,2./ 5+3*z +eps* z -3/5 ;
title 2./ 5+3*z ;
hold on
[y,z] meshgrid -3:0.5:3,-3:0.5:3 ;
x zeros size y ;
mesh x,y,z ; end
function cplxmap1 z,w,B
blue 0.2;
x real z ;
y imag z ;
u real w ;
v imag w ;
if nargin 2 k find abs w B | isnan abs w ; if length k 0 u k B*sign u k ; v k zeros size k ; v v/max max abs v ; v k NaN*ones size k ; end
end
M max max u ;
m min min u ;
axis [-1 1 -1 1 m M] ;
caxis [-1 1] ;
s ones size z ;
surf x,y,u,v ;
colormap hsv 64
End
3、在同一幅图中绘制绘制勒让德函数 的图形(10分)。
解:
程序:
clear all
t 0:0.01:1;
y1 legendre 1,t ;
y2 legendre 2,t ;
y3 legendre 3,t ;
plot t,y1 1,: ,r-,t,y1 2,: ,y-,linewidth,3 ;
hold on
plot t,y2 1,: ,b-,t,y2 2,: ,k-,t,y2 3,: ,m-,linewidth,3 ;
hold on
plot t,y3 1,: ,c-,t,y3 2,: ,g-,t,y3 3,: ,--,t,y3 4,: ,-.,linewidth,3 ;
legend P_1^0,P_1^1,P_2^0,P_2^1,P_2^2,P_3^0,P_3^1,P_3^2,P_3^3 ;
title 勒让德 ;
求任意两个圆相交的区域,并求出相交区域的面积。(注:如果两个圆不相交,输出“两个圆不相交”)(20分)。
程序:
function text4
clear all
char ch;
%画两个圆
r0 100;
r1 100;
x0 0;y0 0;x1 40;y1 60;
ch g;
circle r0,x0,y0,ch ;
ch r;
circle r1,x1,y1,ch ;
%判断两个圆是否相交并求面积
x3 [];
y3 [];
for x -r1:r1 for y -r1:r1 d1 sqrt x-x0 ^2+ y-y0 ^2 ; d2 sqrt x-x1 ^2+ y-y1 ^2 ; if d1 r0 d2 r1 ; x3 [x3,x]; y3 [y3,y]; end end
end
if size x3 0 fprintf 两个圆不想交 ;
else %计算面积 syms a b [a1,b1] solve a-x0 ^2+ b-y0 ^2-r0^2, a-x1 ^2+ b-y1 ^2-r1^2 ; a1 double a1 ; b1 double b1 ; plot x3,y3,k. ; juli sqrt a1 1 -a1 2 ^2+ b1 1 -b1 2 ^2 ; h0 sqrt r0^2- juli/2 ^2 ; h1 sqrt r1^2- juli/2 ^2 ; S r0*r0*acos h0/r0 /2+r1*r1*acos h1/r1 /2- h0+h1 *juli/2; fprintf 输出面积的大小为:\n%f\n,S ;
end
end
function circle r,x0,y0,ch
theta 0:0.01*pi:2*pi;
x1 r*cos theta +x0;
y1 r*sin theta +y0;
plot x1,y1,ch,linewidth,3 ;
axis equ
原创力文档

文档评论(0)