matlab课后习题答案(附图)

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

matlab课后习题答案(附图)习题2.1
画出下列常见曲线的图形
y (1)⽴⽅抛物线3x
命令:syms x y;
ezplot('x.^(1/3)')
(2)⾼斯曲线y=e^(-X^2);
命令:clear
syms x y;
ezplot('exp(-x*x)')
(3)笛卡尔曲线
命令:>> clear
>> syms x y;
>> a=1;
>> ezplot(x^3+y^3-3*a*x*y)
(4)蔓叶线
命令:>> clear
>> syms x y;
>> a=1
ezplot(y^2-(x^3)/(a-x))
(5)摆线:()()t
sin-
=
,
=
-
b
y
1
命令:>> clear
>> t=0:0.1:2*pi;
>> x=t-sin(t);
>>y=2*(1-cos(t)); >> plot(x,y)
7螺旋线
命令:>> clear >> t=0:0.1:2*pi; >> x=cos(t); >> y=sin(t); >> z=t;
>>plot3(x,y,z)
(8)阿基⽶德螺线
命令:clear
>> theta=0:0.1:2*pi;
>> rho1=(theta);
>> subplot(1,2,1),polar(theta,rho1)
(9) 对数螺线
命令:clear
theta=0:0.1:2*pi;
rho1=exp(theta);
subplot(1,2,1),polar(theta,rho1)
(12)⼼形线
命令:>> clear >> theta=0:0.1:2*pi; >> rho1=1+cos(theta); >> subplot(1,2,1),polar(theta,rho1)
练习2.2
1. 求出下列极限值
(1)n
n
n n
3

命令:>>syms n
>>limit((n^3+3^n)^(1/n)) ans = 3
(2))121(lim n n n n ++-+∞

命令:>>syms n
>>limit((n+2)^(1/2)-2*(n+1)^(1/2)+n^(1/2),n,inf) ans = 0(3)x x x 2cot lim 0

命令:syms x ;
>> limit(x*cot(2*x),x,0) ans = 1/2 (4))
(cos
lim
c
m x
x ∞

命令:syms x m ; limit((cos(m/x))^x,x,inf) ans = 1(5))1
1
1(
lim 1
--
→e
x
x x
命令:syms x
>> limit(1/x-1/(exp(x)-1),x,1) ans =
(exp(1)-2)/(exp(1)-1) (6))(
2
lim x x x
x -+∞
>> limit((x^2+x)^(1/2)-x,x,inf)
ans = 1/2
练习2.4
1. 求下列不定积分,并⽤diff 验证:(1)
+x dx
cos 1
>>Clear >> syms x y >> y=1/(1+cos(x)); >> f=int(y,x) f =
tan(1/2*x) >> y=tan(1/2*x); >> yx=diff(y ,x); >> y1=simple(yx) y1 =
1/2+1/2*tan(1/2*x)^2 (2)
+
e
x
dx
1
clear syms x y
y=1/(1+exp(x));
f=int(y,x) f =
-log(1+exp(x))+log(exp(x)) syms x y
y=-log(1+exp(x))+log(exp(x)); yx=diff(y,x); y1=simple(yx) y1 = 1/(1+exp(x)) (3)
dx x x ?sin 2
syms x y
y=x*sin(x)^2; >> f=int(y,x) f =
x*(-1/2*cos(x)*sin(x)+1/2*x)-1/4*cos(x)^2-1/4*x^2 clear
syms x y y=x*(-1/2*cos(x)*sin(x)+1/2*x)-1/4*cos(x)^2-1/4*x^2; yx=diff(y,x); >> y1=simple(yx) y1 = x*sin(x)^2 (4)
xdx ?sec
3
syms x y y=sec(x)^3;
f=int(y,x) f =
1/2/cos(x)^2*sin(x)+1/2*log(sec(x)+tan(x)) clear syms x y
y=1/2/cos(x)^2*sin(x)+1/2*log(sec(x)+tan(x)); yx=diff(y,x); y1=simple(yx) y1 =
1/cos(x)^3
2. 求下列积分的数值解 1)dx x
-10
clear
syms x
y=int(x^(-x),x,0,1) y =
int(x^(-x),x = 0 .. 1) vpa(y,10) ans =
1.291285997 2)xdx e x cos
3
20
2?
π
clear
syms x
y=int(exp(2*x)*cos(x)^3,x, clear syms x
y=int((1/(2*pi)^(1/2))*exp(-x^2/2),x,0,1) y =
7186705221432913/36028797018963968*erf(1/2*2^(1/2))*2^(1/2)*pi^(1/0,2*pi) y =
22/65*exp(pi)^4-22/65vpa(ans,10)
(3)
dx x
e
2
1
2
21-
π
>> clear >> syms x
>> y=int(1/(2*pi)^(1/2)*exp(-x^2/2),0,1); >> vpa(y,14) ans =
.34134474606855
2(4)
>> clear >> syms x
>> y=int(x*log(x^4)*asin(1/x^2),1,3); Warning: Explicit integral could not be found. > In sym.int at 58 >> vpa(y,14) ans = 2.4597721282375
2(5) >> clear >> syms x
1判断下列级数的收敛性,若收敛,求出其收敛值。

1)syms n s1=symsum(1/n^(2^n),n,1,inf)
s1 =
sum(1/(n^(2^n)),n = 1 .. Inf)
vpa(s1,10)
ans =
1.062652416
因此不收敛
2)syms n
s1=symsum(sin(1/n),n,1,inf)
s1 =
sum(sin(1/n),n = 1 .. Inf)
vpa(s1,10)
ans =
sum(sin(1/n),n = 1 .. Inf)
不收敛
(3)
>> clear
>> syms n
>> s=symsum(log(n)/n^3,n,1,inf)
s =
-zeta(1,3)
收敛
(4) syms n
s1=symsum(1/(log10(n))^n,n,3,inf)
s1 =
sum(1/((log(n)/log(10))^n),n = 3 .. inf)
不收敛
(5) syms n
s1=symsum(1/n*log10(n),n,2,inf)
s1 =
sum(1/n*log(n)/log(10),n = 2 .. Inf)
>> syms n
>> s=symsum((-1)^n*n/n^2+1,n,1,inf)
sum((-1)^n/n+1,n = 1 .. Inf)
不收敛
习题3.1
1)clear;
[x,y]=meshgrid(-30:0.3:30);
z=10*sin(sqrt(x.^2+y.^2))./sqrt(1+x.^2+y.^2); >> meshc(x,y,z)
clear
>> [x,y]=meshgrid(-30:0.1:30);
>> z=10*sin((x^2+y^2)^(1/2))/(1+x^2+y^2)^(1/2) mesh(x,y,z)
1.
2.取适当的参数绘制下列曲⾯的图形。

(1)
clear
>> a=-2:0.1:2;
>> b=-3:0.1:3;
>> [x,y]=meshgrid(a,b);
>> z=(1-(x.^2)/4-(y.^2)/9).^(1/2);
>> mesh(x,y,z)
>> hold on
mesh(x,y,-z)
(2)
clear
>> a=-1:0.1:1;
>> b=-2:0.1:2;
[x,y]=meshgrid(a,b);
>> z=(4/9)*(x.^2)+(y.^2);
>> mesh(x,y,z)
>> [x,y]=meshgrid(-1:0.1:1);
>> z=(1/3)*(x.^2)-(1/3)*(y.^2);
>> mesh(x,y,z)
习题3.2
P49/例3.2.1
命令:syms x y
limit(limit((x^2+y^2)/(sin(x)+cos(y)),0),pi), ans =
-pi^2
limit(limit((1-cos(x^2+y^2))/((x^2+y^2)),0),0), ans =
P49/例3.2.2
命令:clear;syms x y z dx dy dz zxz zy zxx zxy z=atan(x^2*y) z =
atan(x^2*y)
zx=diff(z,x),zy=diff(z,y)
zx
2*x*y/(1+x^4*y^2)
zy =
x^2/(1+x^4*y^2)
dz=zx*dx+zy*dy,
dz =
2*x*y/(1+x^4*y^2)*dx+x^2/(1+x^4*y^2)*d
zxx=diff(zx,x),zxy=diff(zx,y)
zxx =
2*y/(1+x^4*y^2)-8*x^4*y^3/(1+x^4*y^2)^2 zxy =
2*x/(1+x^4*y^2)-4*x^5*y^2/(1+x^4*y^2)^2
3.2.1作图表⽰函数z=x*exp(-x^2-y^2) (-1
>> a=-1:0.1:1;
>> b=0:0.1:2;
>> [x,y]=meshgrid(a,b);
>> z=x.*exp(-x.^2-y.^2);
>> [px,py]=gradient(z,0.1,0.1);
contour(a,b,z),hold on,
1.解下列微分⽅程
(1)y=dsolve('Dy=x+y','y(0)=1','x')
y =
-x-1+2*exp(x)
x=[1 2 3]
x = 1 2 3
-x-1+2*exp(x)
ans =
3.4366 11.7781 36.1711
(2)x'=2*x+3*y,y'=2*x+y,x(0)=-2,y(0)=2.8,0
新建M函数
function dy=weifen1(t,y)
dy=zeros(2,1);
dy(1)=2*y(1)+3*y(2);
dy(2)=2*y(1)+y(2);
输⼊命令
>> t=0:0.1:10;
>> [t,y]=ode15s('weifen1',[0,10],[-2 2.8]);
>> plot(t,y)
(3)y''-0.01(y')^2+2*y1=sin(t),y(0)=0,y'(0)=1,0 function dy=weifen2(t,y)
dy=zeros(2,1);
dy(1)=y(2);
dy(2)=0.01*y(2)^2-2*y(1)+sin(t);
输⼊命令
>> [t,y]=ode15s('weifen2',[0,5],[0 1]);
>> plot(t,y)
1.绘制飞船轨迹图
新建M函数
function dy=weifen3(t,y)
dy(3)=2*y(4)+y(1)-(1-1/82.45)*(y(1)+
1/82.45)/((y(1)+1/82.45)^2+y(2)^2)^(3/2)-(1/82.45)*(y(1)+1/82.45-1)/((y(1)+1-1/82.45)^2+y(2)^ 2)^(3/2);
dy(4)=-2*y(3)+y(2)-(1-1/82.45)*y(2)^2/((y(1)+1/82.45)^2+y(2)^2)^(3/2)-(1/82.45)*y(2)/((y(1)+1 -1/82.45)^2+y(2)^2)^(3/2);输⼊命令
>> [t,y]=ode15s('weifen3',[0,10],[1.2 0 0 -1]);
>> plot(t,y)
习题4.1
4.1.5(1)>> clear
>> p=[1 0 1];
q=[1 0 0 0 1];
[a,b,r]=residue(p,q)
a =
-0.0000 - 0.3536i
-0.0000 + 0.3536i
0.0000 - 0.3536i
0.0000 + 0.3536i
b =
-0.7071 + 0.7071i
-0.7071 - 0.7071i
0.7071 + 0.7071i
0.7071 - 0.7071i
>> r =
[]
>> format rat
a
a =
-1/6369051672525780 - 1189/3363i
-1/6369051672525779 + 1189/3363i
1/5095241338020627 - 1189/3363i
1/5095241338020627 + 1189/3363i
4.1.5(2)>> p=[1];
0.1768 - 0.1768i
0.1768 + 0.1768i
-0.1768 - 0.1768i
-0.1768 + 0.1768i
b =
-0.7071 + 0.7071i
-0.7071 - 0.7071i
0.7071 + 0.7071i
0.7071 - 0.7071i
r =
[]
>> format rat
>> a
a =
1189/6726 - 1189/6726i
1189/6726 + 1189/6726i
-1189/6726 - 1189/6726i
-1189/6726 + 1189/6726i
习题4.2
4.2.1(1)
>> clear
>> D=[2 1 3 1;3 -1 2 1;1 2 3 2;5 0 6 2]; >> det(D)
ans =
6
4.3.3(1)
>> clear
>> A=[0 1 0;1 0 0;0 0 1];
>> B=[1 0 0;0 0 1;0 1 0];
>> C=[1 -4 3;2 0 -1;1 -2 0];
>> X=C*inv(A)*inv(B)
X =
-4 3 1
0 -1 2
习题4.3
4.3.3(2)
>> clear
>> D=[1 2 3;2 2 3;3 5 1];
>> D1=[1 2 3;2 2 3;3 5 1];
>> D2=[1 1 3;2 2 3;3 3 1];
>> D3=[1 2 1;2 2 2;3 5 3];X1=det(D1)/det(D);X2=det(D2)/det(D);X3=det(D3)/det(D); >> X1,X2,X3 X1 =
1
X2 =
X3 =
4.4.1(1)
>> clear
>> A=[4 2 -1;3 -1 2;3 -1 2;11 3 0];
>> B=[4 2 -1 2;3 -1 2 10;11 3 0 8];
>> rank(A),RANK(B)
ans =
2
Warning: Function call RANK invokes inexact match E:\toolbox\matlab\matfun\rank.m. ans =
3
习题4.4
4.4.1(3)
clear
>> A=[1 1 1 1;1 2 -1 4;2 -3 -1 -5;3 1 2 11];
>> B=[1 1 1 1 5;1 2 -1 4 -2;2 -3 -1 -5 -2;3 1 2 11 0];
>> rank(A),rank(B)
ans =
4
ans =
4
习题4.5
4.5.1(3)
>> clear
>> A=[4 1 -1;3 2 -6;1 -5 3];
>> [a,b]=eig(A)
a =
92/4963 -1237/1373 -424/1383
-627/815 -449/3622 -1301/1795
-1122/1757 -1097/2638 559/906
b =
-4695/1538 0 0
0 1963/534 0
0 0 8318/993
4.5.1(5)
>> clear
>> A=[5 7 6 5;7 10 8 7;6 8 10 9;5 7 9 10];
>> [a,b]=eig(A)
a =
431/519 308/3301 472/1191 551/1449 -641/1278 -2209/7323 1175/1911 2100/3973 -434/2081 1050/1381 -855/3148 494/895 368/2975 -1049/1848 -3157/5048 473/908
b =
23/2266 0 0 0
0 1639/1944 0 0
0 0 3615/937 0
0 0 0 2938/97
4.5.3
>> clear
>> A=[2 0 0;0 3 2;0 2 3];
>> [a,b]=eig(A);。

相关文档
最新文档