《MATLAB语言与应用》实验课程任务书.docx
《《MATLAB语言与应用》实验课程任务书.docx》由会员分享,可在线阅读,更多相关《《MATLAB语言与应用》实验课程任务书.docx(48页珍藏版)》请在冰点文库上搜索。
《MATLAB语言与应用》实验课程任务书
《MATLAB语言与应用》实验课程任务书
第一部分MATLAB语言编程、科学绘图与基本数学问题求解(4学时)
2.用MATLAB语句输入矩阵
和
,
前面给出的是
矩阵,如果给出
命令将得出什么结果?
>>A=[1234;4321;2341;3241]
A=
1234
4321
2341
3241
>>B=[1+4j2+3j3+2j4+1j;4+1j3+2j2+3j1+4j;2+3j3+2j4+1j1+4j;3+2j2+3j4+1j1+4j]
B=
1.0000+4.0000i2.0000+3.0000i3.0000+2.0000i4.0000+1.0000i
4.0000+1.0000i3.0000+2.0000i2.0000+3.0000i1.0000+4.0000i
2.0000+3.0000i3.0000+2.0000i4.0000+1.0000i1.0000+4.0000i
3.0000+2.0000i2.0000+3.0000i4.0000+1.0000i1.0000+4.0000i
>>A(5,6)=5
A=
123400
432100
234100
324100
000005
3.假设已知矩阵
,试给出相应的MATLAB命令,将其全部偶数行提取出来,赋给
矩阵,用
命令生成
矩阵,用上述命令检验一下结果是不是正确。
>>A=magic(8)
A=
642361606757
955541213515016
1747462021434224
4026273736303133
3234352928383925
4123224445191848
4915145253111056
858595462631
>>B=A(2:
2:
end,:
)
B=
955541213515016
4026273736303133
4123224445191848
858595462631
4.用数值方法可以求出
,试不采用循环的形式求出和式的数值解。
由于数值方法是采用double形式进行计算的,难以保证有效位数字,所以结果不一定精确。
试采用运算的方法求该和式的精确值。
>>formatlong;sum(2.^[0:
63])
ans=
1.844674407370955e+019
>>symsk;
s=symsum(2^k,0,63)
s=
184********709551615
5.选择合适的步距绘制出下面的图形。
(1)
,其中
;
(2)
,其中
。
(1)>>t=[-1:
0.003:
1];
>>y=sin(1./t);
>>plot(t,y)
(2)>>t=[-pi:
0.02:
-1.7,-1.7:
0.001:
-1.3,-1.3:
0.03:
1.2,1.2:
0.001:
1.8,1.8:
0.05:
pi];
>>y=sin(tan(t))-tan(sin(t));
>>plot(t,y)
6.试绘制出二元函数
的三维图和三视图。
>>x1=[-2:
0.1:
-1.2,-1.1:
0.02:
-0.9,-0.8:
0.1:
0.8,0.9:
0.02:
1.1,1.2:
0.1:
2];
y1=[-1:
0.1:
-0.2,-0.1:
0.02:
0.1,0.2:
0.1:
1];
[x,y]=meshgrid(x1,y1);
z=1./sqrt((1-x).^2+y.^2)+1./sqrt((1+x).^2+y.^2);
surf(x,y,z),shadingflat;zlim([0,15])
>>subplot(224);surf(x,y,z);shadingflat;title('正视图');
subplot(223);surf(x,y,z);shadingflat;view(0,0);title('右视图');
subplot(221);surf(x,y,z);shadingflat;view(90,0);title('左视图')
subplot(222);surf(x,y,z);shadingflat;view(0,90);title('俯视图');
7.试求出如下极限。
(1)
;
(2)
;(3)
。
(1)>>symsx;f=(3.^x+9.^x).^(1./x);L=limit(f,x,inf)
L=
9
(2)>>symsxy;f=(x.*y)/(sqrt(x.*y+1)-1);
>>L=limit(limit(f,x,0),y,0)
L=
2
(3)>>symsxy;f=(1-cos(x.^2+y.^2))./((x.^2+y.^2).*exp(x.^2+y.^2));
>>L=limit(limit(f,x,0),y,0)
L=
0
.
8.已知参数方程
,试求出
和
。
自定义函数:
functionresult=paradiff(y,x,t,n)
ifmod(n,1)~=0,error('nshouldpositiveinteger,pleasecorrect')
else
ifn==1,result=diff(y,t)./diff(x,t);
else,result=diff(paradiff(y,x,t,n-1),t)./diff(x,t);
end,end
(1)>>symst;x=log(cos(t));y=cos(t)-t.*sin(t);
f=paradiff(y,x,t,1);
>>[n,d]=numden(f);F=simple(n)./simple(d)
F=
(t*cos(t)^2+sin(2*t))/sin(t)
(2)>>symst;x=log(cos(t));y=cos(t)-t.*sin(t);
>>f=paradiff(y,x,t,1);
>>f=paradiff(y,x,t,2);
>>[n,d]=numden(f);F=simple(n)./simple(d)
F=
(2*t*cos(t)^2-3*sin(t)*cos(t)^3-t*cos(t)^4+2*sin(t)*cos(t))/sin(t)^3
>>f1=subs(F,t,pi./3)
f1=
1.5387
9.假设
,试求
。
>>symsxyt;g=exp(-t^2);
>>f=simple(int(g,t,0,x*y));
>>G=(x/y)*(diff(f,x,2))-2*(diff(diff(f,x),y))+diff(f,y,2)
G=
2*x^2*y^2*exp(-x^2*y^2)-2*exp(-x^2*y^2)-2*x^3*y*exp(-x^2*y^2)
10.试求出下面的极限。
(1)
;
(2)
。
(1)>>symskn;limit(symsum(1/((2*k)^2-1),k,1,n),n,inf)
ans=
1/2
(2)
>>symskn;limit(n*symsum(1/(n^2+k*pi),k,1,n),n,inf)
ans=
1
11.试求出以下的曲线积分。
(1)
,
为曲线
,
,
。
(2)
,其中
为
正向上半椭圆。
(1)>>symsta;x=a*(cos(t)+t*sin(t));y=a*(sin(t)-t*cos(t));
>>I=int((x^2+y^2)*sqrt(diff(x,t)^2+diff(y,t)^2),t,0,2*pi)
I=
2*pi^2*a^3*(2*pi^2+1)
(2)>>symst;symsabcpositive;
>>x=a/c*cos(t);y=b/c*sin(t);
>>F=[y*x^3+exp(y),x*y^3+x*exp(y)-2*y];
>>ds=[diff(x,t);diff(y,t)];
>>I=int(F*ds,t,0,pi)
I=
2/15*a*(2*b^4-15*c^4)/c^5
12.试求出Vandermonde矩阵
的行列式,并以最简的形式显示结果。
自定义函数:
functionA=vander(v)
n=length(v);
v=v(:
);A=sym(ones(n));
forj=n-1:
-1:
1,A(:
j)=v.*A(:
j+1);end
>>symsabcde;
c=[a,b,c,d,e];
V=vander(c);
s1=simple(det(V))
s1=
(a-b)*(a-c)*(a-d)*(b-c)*(a-e)*(b-d)*(b-e)*(c-d)*(c-e)*(d-e)
13.试对矩阵
进行Jordan变换,并得出变换矩阵。
>>A=[-2,0.5,-0.5,0.5;0,-1.5,0.5,-0.5;2,0.5,-4.5,0.5;2,1,-2,-2];
>>[V,J]=jordan(A)
V=
00.50000.5000-0.2500
000.50001.0000
0.25000.50000.5000-0.2500
0.25000.50001.0000-0.2500
J=
-4000
0-210
00-21
000-2
14.试用数值方法和解析方法求取下面的Sylvester方程,并验证得出的结果。
>>A=[3,-6,-4,0,5;1,4,2,-2,4;-6,3,-6,7,3;-13,10,0,-11,0;0,4,0,3,4];
B=[3,-2,1;-2,-9,2;-2,-1,9];C=[-2,1,-1;4,1,2;5,-6,1;6,-4,-4;-6,6,-3];
数值解
X=lyap(A,B,C)
X=
-4.0569-14.51281.5653
0.035625.0743-2.7408
9.488625.9323-4.4177
2.696921.6450-2.8851
7.722931.9100-3.7634
>>norm(A*X+X*B+C)
ans=
2.7917e-013
解析解
>>A=sym(A);X=lyap(A,B,C)
X=
4.056914.5128-1.5653
-0.0356-25.07432.7408
-9.4886-25.93234.4177
-2.6969-21.64502.8851
-7.7229-31.91003.7634
>>norm(double(A*X+X*B+C))
ans=
4.3904e-13
解析解与实际不符
15.假设已知矩阵
如下,试求出
,
,
。
>>A=[-4.5,0,0.5,-1.5;-0.5,-4,0.5,-0.5;1.5,1,-2.5,1.5;0,-1,-1,-3];
>>exp(A.*t)
ans=
[1/exp((9*t)/2),1,exp(t/2),1/exp((3*t)/2)]
[1/exp(t/2),1/exp(4*t),exp(t/2),1/exp(t/2)]
[exp((3*t)/2),exp(t),1/exp((5*t)/2),exp((3*t)/2)]
[1,1/exp(t),1/exp(t),1/exp(3*t)]
>>sin(A.*t)
ans=
[-sin(9/2*t),0,sin(t/2),-sin(3/2*t)]
[-sin(1/2*t),-sin(4*t),sin(t/2),-sin(1/2*t)]
[sin((3*t)/2),sin(t),-sin(5/2*t),sin((3*t)/2)]
[0,-sin(t),-sin(t),-sin(3*t)]
>>exp(A*t)*sin(A^2*exp(A*t)*t)
ans=
[exp(-9/2*t)*sin(t*(21*exp(-9/2*t)+2*exp(-1/2*t)-2*exp(3/2*t)+12))+sin(t*(5*exp(-9/2*t)+17*exp(-1/2*t)-3*exp(3/2*t)+5))+exp(1/2*t)*sin(t*(-11*exp(-9/2*t)-8*exp(-1/2*t)+6*exp(3/2*t)-11))+exp(-3/2*t)*sin(t*(-exp(-9/2*t)+6*exp(-1/2*t)+5*exp(3/2*t)+8)),exp(-9/2*t)*sin(t*(21+2*exp(-4*t)-2*exp(t)+12*exp(-t)))+sin(t*(5+17*exp(-4*t)-3*exp(t)+5*exp(-t)))+exp(1/2*t)*sin(t*(-11-8*exp(-4*t)+6*exp(t)-11*exp(-t)))+exp(-3/2*t)*sin(t*(-1+6*exp(-4*t)+5*exp(t)+8*exp(-t))),exp(-9/2*t)*sin(t*(23*exp(1/2*t)-2*exp(-5/2*t)+12*exp(-t)))+sin(t*(22*exp(1/2*t)-3*exp(-5/2*t)+5*exp(-t)))+exp(1/2*t)*sin(t*(-19*exp(1/2*t)+6*exp(-5/2*t)-11*exp(-t)))+exp(-3/2*t)*sin(t*(5*exp(1/2*t)+5*exp(-5/2*t)+8*exp(-t))),exp(-9/2*t)*sin(t*(21*exp(-3/2*t)+2*exp(-1/2*t)-2*exp(3/2*t)+12*exp(-3*t)))+sin(t*(5*exp(-3/2*t)+17*exp(-1/2*t)-3*exp(3/2*t)+5*exp(-3*t)))+exp(1/2*t)*sin(t*(-11*exp(-3/2*t)-8*exp(-1/2*t)+6*exp(3/2*t)-11*exp(-3*t)))+exp(-3/2*t)*sin(t*(-exp(-3/2*t)+6*exp(-1/2*t)+5*exp(3/2*t)+8*exp(-3*t)))]
[exp(-1/2*t)*sin(t*(21*exp(-9/2*t)+2*exp(-1/2*t)-2*exp(3/2*t)+12))+exp(-4*t)*sin(t*(5*exp(-9/2*t)+17*exp(-1/2*t)-3*exp(3/2*t)+5))+exp(1/2*t)*sin(t*(-11*exp(-9/2*t)-8*exp(-1/2*t)+6*exp(3/2*t)-11))+exp(-1/2*t)*sin(t*(-exp(-9/2*t)+6*exp(-1/2*t)+5*exp(3/2*t)+8)),exp(-1/2*t)*sin(t*(21+2*exp(-4*t)-2*exp(t)+12*exp(-t)))+exp(-4*t)*sin(t*(5+17*exp(-4*t)-3*exp(t)+5*exp(-t)))+exp(1/2*t)*sin(t*(-11-8*exp(-4*t)+6*exp(t)-11*exp(-t)))+exp(-1/2*t)*sin(t*(-1+6*exp(-4*t)+5*exp(t)+8*exp(-t))),exp(-1/2*t)*sin(t*(23*exp(1/2*t)-2*exp(-5/2*t)+12*exp(-t)))+exp(-4*t)*sin(t*(22*exp(1/2*t)-3*exp(-5/2*t)+5*exp(-t)))+exp(1/2*t)*sin(t*(-19*exp(1/2*t)+6*exp(-5/2*t)-11*exp(-t)))+exp(-1/2*t)*sin(t*(5*exp(1/2*t)+5*exp(-5/2*t)+8*exp(-t))),exp(-1/2*t)*sin(t*(21*exp(-3/2*t)+2*exp(-1/2*t)-2*exp(3/2*t)+12*exp(-3*t)))+exp(-4*t)*sin(t*(5*exp(-3/2*t)+17*exp(-1/2*t)-3*exp(3/2*t)+5*exp(-3*t)))+exp(1/2*t)*sin(t*(-11*exp(-3/2*t)-8*exp(-1/2*t)+6*exp(3/2*t)-11*exp(-3*t)))+exp(-1/2*t)*sin(t*(-exp(-3/2*t)+6*exp(-1/2*t)+5*exp(3/2*t)+8*exp(-3*t)))]
[exp(3/2*t)*sin(t*(21*exp(-9/2*t)+2*exp(-1/2*t)-2*exp(3/2*t)+12))+exp(t)*sin(t*(5*exp(-9/2*t)+17*exp(-1/2*t)-3*exp(3/2*t)+5))+exp(-5/2*t)*sin(t*(-11*exp(-9/2*t)-8*exp(-1/2*t)+6*exp(3/2*t)-11))+exp(3/2*t)*sin(t*(-exp(-9/2*t)+6*exp(-1/2*t)+5*exp(3/2*t)+8)),exp(3/2*t)*sin(t*(21+2*exp(-4*t)-2*exp(t)+12*exp(-t)))+exp(t)*sin(t*(5+17*exp(-4*t)-3*exp(t)+5*exp(-t)))+exp(-5/2*t)*sin(t*(-11-8*exp(-4*t)+6*exp(t)-11*exp(-t)))+exp(3/2*t)*sin(t*(-1+6*exp(-4*t)+5*exp(t)+8*exp(-t))),exp(3/2*t)*sin(t*(23*exp(1/2*t)-2*exp(-5/2*t)+12*exp(-t)))+exp(t)*sin(t*(22*exp(1/2*t)-3*exp(-5/2*t)+5*exp(-t)))+exp(-5/2*t)*sin(t*(-19*exp(1/2*t)+6*exp(-5/2*t)-11*exp(-t)))+exp(3/2*t)*sin(t*(5*exp(1/2*t)+5*exp(-5/2*t)+8*exp(-t))),exp(3/2*t)*sin(t*(21*exp(-3/2*t)+2*exp(-1/2*t)-2*exp(3/2*t)+12*exp(-3*t)))+exp(t)*sin(t*(5*exp(-3/2*t)+17*exp(-1/2*t)-3*exp(3/2*t)+5*exp(-3*t)))+exp(-5/2*t)*sin(t*(-11*exp(-3/2*t)-8*exp(-1/2*t)+6*exp(3/2*t)-11*exp(-3*t)))+exp(3/2*t)*sin(t*(-exp(-3/2*t)+6*exp(-1/2*t)+5*exp(3/2*t)+8*exp(-3*t)))]
[sin(t*(21*exp(-9/2*t)+2*exp(-1/2*t)-2*exp(3/2*t)+12))+exp(-t)*sin(t*(5*exp(-9/2*t)+17*exp(-1/2*t)-3*exp(3/2*t)+5))+exp(-t)*sin(t*(-11*exp(-9/2*t)-8*exp(-1/2*t)+6*exp(3/2*t)-11))+exp(-3*t)*sin(t*(-exp(-9/2*t)+6*exp(-1/2*t)+5*exp(3/2*t)+8)),sin(t*(21+2*exp(-4*t)-2*exp(t)+12*exp(-t)))+exp(-t)*sin(t*(5+17*exp(-4*t)-3*exp(t)+5*exp(-t)))+exp(-t)*sin(t*(-11-8*exp(-4*t)+6*exp(t)-11*exp(-t)))+exp(-3*t)*sin(t*(-1+6*exp(-4*t)+5*exp(t)+8*exp(-t))),sin(t*(23*exp(1/2*t)-2*exp(-5/2*t)+12*exp(-t)))+exp(-t)*sin(t*(22*exp(1/2*t)-3*exp(-5/2*t)+5*exp(-t)))+exp(-t)*sin(t*(-19*exp(1/2*t)+6*exp(-5/2*t)-11*exp(-t)))+exp(-3*t)*sin(t*(5*exp(1/2*t)+5*exp(-5/2*t)+8*exp(-t))),sin(t*(21*exp(-3/2*t)+2*exp(-1/2*t)-2*exp(3/2*t)+12*exp(-3*t)))+exp(-t)*sin(t*(5*exp(-3/2*t)+17*exp(-1/2*t)-3*exp(3/2*t)+5*exp(-3*t)))+exp(-t)*sin(t*(-11*exp(-3/2*t)-8*exp(-1/2*t)+6*exp(3/2*t)-11*exp(-3*t)))+exp(-3*t)*sin(t*(-exp(-3/2*t)+6*exp(-1/2*t)+5*exp(3/2*t)+8*exp(-3*t)))]
第二部分数学问题求解与数据处理(4学时)
主要内容:
掌握代数方程与最优化问题、微分方程问题、数据处理问题的MATLAB求解方法。
1.对下列的函数
进行Laplace变换。
(1)
;
(2)
;(3)
(1)>>symst;f=sin(a.*t)./t;F=laplace(f)
F=
atan(a/s)
(2)>>symsta;f=t.^5.*sin(a.*t);F=laplace(f);
>>s1=simple(F)
s1=
120/(s^2+a^2)^3*sin(6*atan(a/s))
(3)>>symsta;f=t.^8.*cos(a.*t);F=laplace(f);
>>s1=simple(F)
s1=
40320/(s^2+a^2)^(9/2)*cos(9*atan(a/s))
2.对下面的
式进行Laplace反变换。
(1)
;
(2)
;(3)
。