MATLABLE习题.docx
《MATLABLE习题.docx》由会员分享,可在线阅读,更多相关《MATLABLE习题.docx(11页珍藏版)》请在冰豆网上搜索。
MATLABLE习题
习题1:
1.T=atan((2*pi*A+E/(2*pi*B*C))/D)
T= 1.1371
2.exp(a+b)/log10(a+b)
ans= 6.3351e+005
3.30;94.2478;706.8583
4.
>>a=8.5;b=14.6;c=18.4;
>>s=(a+b+c)/2
s= 20.7500
>>area=sqrt(s*(s-a)*(s-b)*(s-c))
area= 60.6106
习题2:
1.>>A=[311
212
123];
>>B=[11-1;2-10;1-11];
>>2*A+B
ans=
7 3 1
6 1 4
3 3 7
>>4*A^2-3*B^2
ans=
42 21 38
40 19 46
40 33 56
>>A*B
ans=
6 1 -2
6 -1 0
8 -4 2
>>B*A
ans=
4 0 0
4 1 0
来源:
(-MATLAB 程序设计与应用(刘卫国版)习题答案1-2_zdld_新浪博客
2 2 2
>>A*B-B*A
ans=
2 1 -2
2 -2 0
6 -6 0
2.B=inv(inv(A)-eye(3))*6*eye(3)
B= 3 0 0
0 2 0
0 0 1
3.A=inv(2*eye(4)-C^(-1)*B)*C^(-1)
A=A'
A= 1 0 0 0
-2 1 0 0
1 -2 1 0
0 1 -2 1
4.>>A=[2-1
-12];
>>B=[0-2;-20];
>>X=(B+2*A)/2;
X= 2 -2
-2 2
5.a=[2-302;1521;3-11-1;4122];
b=[8;2;7;12];
X=a\b;
X= 3.0000 0.0000 -1.0000 1.0000
6.p=[31247081];
x=roots(p)
x= -3.8230
-0.5275+0.8497i
-0.5275-0.8497i
0.5007+0.6749i
0.5007-0.6749i
-0.1234
7.a=[31247081];
b=conv([1-3],[1050]);
[div,rest]=deconv(a,b)
div= 3 21 52
rest= 0 0 0 103 55 788 1
习题3:
1.
>>symsxf
>>f=limit((cos(sqrt(x)))^(pi/x),x,0,'right')
f=exp(-1/2*pi)
2.
>>symsxf
>>f=limit((3*sin(x)+x^2*cos(1/x))/((1+cos(x))*log(1+x)),x,0)
f=3/2
3.
>>symsxf
>>f=limit((sqrt(4*x^2+x-1)+x+1)/sqrt(x^2+sin(x)),x,-inf)
f=1
4.
>>symsxyf
>>f=limit(limit((x^2+y^2)^(x^2*y^2),x,0),y,0)
f=1
5.
>>symsxyf
>>y=(tan(sqrt(x+sqrt(x+sqrt(2*x)))))^2
y=tan((x+(x+2^(1/2)*x^(1/2))^(1/2))^(1/2))^2
>>f=diff(y)
f=
tan((x+(x+2^(1/2)*x^(1/2))^(1/2))^(1/2))*(1+tan((x+(x+2^(1/2)*x^(1/2))^(1/2))^(1/2))^2)/(x+(x+2^(1/2)*x^(1/2))^(1/2))^(1/2)*(1+1/2/(x+2^(1/2)*x^(1/2))^(1/2)*(1+1/2*2^(1/2)/x^(1/2)))
6.
>>symsxyf
>>y=(cos(x^2))*(sin(1/x))^2
y=cos(x^2)*sin(1/x)^2
>>f=diff(y)
f=
-2*sin(x^2)*x*sin(1/x)^2-2*cos(x^2)*sin(1/x)*cos(1/x)/x^2
7.
>>symsxf
>>f=int(sqrt(sin(x)-(sin(x))^3),'x',0,pi)
f=4/3
8.
>>symsxf
>>f=int(1/x*sqrt((x+1)/(x-1)))
f=
((1+x)/(x-1))^(1/2)*(x-1)/((1+x)*(x-1))^(1/2)*(-atan(1/(x^2-1)^(1/2))+log(x+(x^2-1)^(1/2)))
9.
>symsxyf
>>f=dsolve('D2y+4*Dy+4*y=exp(-2*x)','x')
f=
1/2*x^2*exp(-2*x)+C1*exp(-2*x)+C2*exp(-2*x)*x
10.
>>symsxyf
>>f=dsolve('x^2*Dy+x*y=y^2','y
(1)=1','x')
f=2*x/(1+x^2)
习题4:
1.
>>A=[1240510112131];
>>plot(A)
2.
来源:
(-MATLAB 程序设计与应用(刘卫国版)习题答案3-4_zdld_新浪博客
(1)
t=[0:
0.01:
2*pi];
x=sin(t);
y=cos(t);
plot(x,y)
axis([-1.51.5-1.51.5])
%限定x轴和y轴的显示范围
gridon
axis('equal')
(2)
t=0:
0.1:
2*pi;
x=sin(t);
y=cos(t);
z=x+y*i;
plot(z)
axisequal
3.已知伏安曲线为U=IR,R分别为1欧姆,5欧姆,10欧姆,20欧姆。
(1)在一张图上画出I在(0-2Π)范围内的U曲线,
(2)添加标题“伏安曲线U=IR”
(3)添加横纵座标的单位“安培”,“伏特”;
(4)添加标出每条线代表的方程。
I=0:
pi/20:
2*pi;
R1=1.0;
R2=5.0;
R3=10.0;
R4=20.0;
U1=I*R1;
U2=I*R2;
U3=I*R3;
U4=I*R4;
plot(I,U1,I,U2,I,U3,I,U4);
plot(I,U1,I,U2,I,U3,I,U4);
title('伏安曲线U=IR');
xlabel('安培');
ylabel('伏特');
legend('U=I','U=5I','U=10I','U=20I');
4.file---importdata---4---A4
x=A4(:
1);
y=[A4(:
2)A4(:
3)];
bar(x,y)
5.A=[1111111
1222221
1223221
1222221
1111111];
>>plot(A)
>>bar(A)
6.x=-1:
0.01:
1;
y=-1:
0.01:
1;
[X,Y]=meshgrid(x,y);
Z=X.^2+Y.^2;
surf(X,Y,Z);
7.[X,Y,Z]=ELLIPSOID(0,0,0,2,3,4);
surf(X,Y,Z)
view([001])
view([010])
totrySPHEREandCYLINDERyourself
MATLAB 程序设计与应用(刘卫国版)习题答案5
(2009-09-3009:
15:
22)
转载
标签:
教育
functionp=excise0501(x1,x2)
x1=-1:
0.01:
1;
x2=-1:
0.01:
1; %[X,Y]=meshgrid(x1,x2);
fori=1:
201
forj=1:
201
ifx1(i)+x2(j)>1.0,
p(i,j)=0.5457*exp(-0.75*x2(j)^2-3.75*x1(i)^2-x1(i)*1.5);
elseifx1(i)+x2(j)<=1.0&x1(i)+x2(j)>-1.0,
p(i,j)=0.7575*exp(-x2(j)^2-6.0*x1(i));
elseifx1(i)+x2(j)<=-1.0,
p(i,j)=0.5457*exp(-0.75*x2(j)^2-3.75*x1(i)^2+x1(i)*1.5);
end
end
end
surf(x1,x2,p);
2.functionFibonacci1
a
(1)=1;a
(2)=1;i=2;
whilei<20
a(i+1)=a(i-1)+a(i);
i=i+1;
end
i,a,
3.functionS=excise0503(a,b)
a=0.0;b=1.0;
dx=linspace(a,b,1001);
h=(a+b)/1000;
S=0.0;
fori=1:
1000
S=S+(sin(dx(i))+sin(dx(i+1)))*h/2;
end
S
4.functionf=excise0504(x)
ifnargin==0,x=0.5;end;
ifabs(x)>=1
break
end
f=x;
k=1;
u=1;
whilenorm(u,1)>0
u=factorial(2*k)*x^(2*k+1)/(2^(2*k)*factorial(k)^2*(2*k+1));
f=f+u;
k=k+1;
end
f
5.functionn=excise0505
n=1;m=1;
fori=2:
1:
9
ifmod(i,2)~=0
m=i;
n=[n,m];
end
end
[x,y]=size(n);
n=n(2:
y);
%n;
fori=10:
1:
99
m=fix(i/10)+mod(i,10);
ifmod(m,2)~=0
n=[n,i];
end
end
%n;
fori=100:
1:
999
m=fix(i/100)+fix(mod(i,100)/10)+mod(i,10);
ifmod(m,2)~=0
n=[n,i];
end
end
%n;
m=fix(sqrt(999));
[x,y]=size(n);
fori=1:
y
forj=2:
m
ifmod(n(i),j)==0&j~=n(i)
n(i)=2;
end
end
end
p=1;
fori=1:
y
ifn(i)~=2
p=[p,n(i)];
end
end
n=p;
[x,y]=size(n);
n=n(2:
y);
n
6.
functionexcise0506
n=input('Pleaseinputn=');
W=[232425];
fori=1:
n
student(i).geometry=input('Pleaseinputgeometry=');
student(i).math=input('Pleaseinputmath=');
student(i).physics=input('Pleaseinputphysics=');
student(i).english=input('Pleaseinputenglish=');
student(i).chinese=input('Pleaseinputchinese=');
student(i).chemistry=input('Pleaseinputchemistry=');
student(i).total=student(i).geometry*W
(1)+student(i).math*W
(2)...
+student(i).physics*W(3)+student(i).english*W(4)...
+student(i).chinese*W(5)+student(i).chemistry*W(6);
student(i).total=student(i).total/6
end