东北大学满分Matlab实验报告.docx
《东北大学满分Matlab实验报告.docx》由会员分享,可在线阅读,更多相关《东北大学满分Matlab实验报告.docx(26页珍藏版)》请在冰豆网上搜索。
东北大学满分Matlab实验报告
第一部分MATLAB语言编程、科学绘图与基本数学问题求解
2.用MATLAB语句输入矩阵
和
,
前面给出的是
矩阵,如果给出
命令将得出什么结果?
解:
A=[1234;4321;2341;3241]
B=[1+4j2+3j3+2j4+1j;4+j3+2j2+3j1+4j;2+3j3+2j4+1j1+4j;3+2j2+3j4+j1+4j]
A(5,6)=5
第五行第六列为5,其余空位补0;
3.假设已知矩阵
,试给出相应的MATLAB命令,将其全部偶数行提取出来,赋给
矩阵,用
命令生成
矩阵,用上述命令检验一下结果是不是正确。
解:
A=[1234;4321;2341;3241]
B=A(2:
2:
end,:
)
A=magic(8)
4.用数值方法可以求出
,试不采用循环的形式求出和式的数值解。
由于数值方法是采用double形式进行计算的,难以保证有效位数字,所以结果不一定精确。
试采用运算的方法求该和式的精确值。
解:
a=0:
63;
s=sum(2.^a)
s=1.8447e+019
symsk;
s=symsum(2^k,0,63)
s=184********709551615
5选择合适的步距绘制出下面的图形。
(1)
,其中
;
(2)
,其中
。
解:
(1)t=[-1:
0.014:
1];
y=sin(1./t);
plot(t,y)
(2)t=[-pi:
0.05:
pi];
y=sin(tan(t))-tan(sin(t));
plot(t,y)
6试绘制出二元函数
的三维图和三视图。
解:
[x,y]=meshgrid(-2:
.1:
2);
z=1./(sqrt((1-x).^2+y.^2))+1./(sqrt((1+x).^2+y.^2));
subplot(224),surf(x,y,z)
subplot(221),surf(x,y,z),view(0,90);%俯视图
subplot(222),surf(x,y,z),view(90,0);%侧视图
subplot(223),surf(x,y,z),view(0.0);%正视图
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已知参数方程
,试求出
和
。
解:
symst;
x=log(cos(t));
y=cos(t)-t*sin(t);
f=diff(y,t)/diff(x,t)
f1=diff(y,t,2)/diff(x,t,2)
L=subs(f1,t,pi/3)
f=(cos(t)*(2*sin(t)+t*cos(t)))/sin(t)
f1=(3*cos(t)-t*sin(t))/(sin(t)^2/cos(t)^2+1)
L=3/8-(pi*3^(1/2))/24
9假设
,试求
。
解:
symsxyt;
f=int(exp(-t^2),t,0,x*y)
f1=x/y*diff(f,x,2)-2*diff(diff(f,x),y)+diff(f,y,2)
f1=2*x^2*y^2*exp(-x^2*y^2)-2*x^3*y*exp(-x^2*y^2)-2*exp(-x^2*y^2)
10试求出下面的极限。
(1)
;
(2)
。
解:
(1)symsmn;
s=limit(symsum(1/((2*m)^2-1),m,1,n),n,inf)
s=1/2
(2)symsnm;
f=limit(symsum(1/(n^2+m*pi),m,1,n),n,inf)
f=0
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*(2*pi^2+1)*(a^2)^(3/2)
(2)symstab;
symscpositive;
x=(c/a)^2*cos(t);
y=(c/b)^2*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,2*pi)
I=0
12试求出Vandermonde矩阵
的行列式,并以最简的形式显示结果。
解:
symsabcde;
C=[a,b,c,d,e];
V=vander(C)
simplify(det(V))
V=
[a^4,a^3,a^2,a,1]
[b^4,b^3,b^2,b,1]
[c^4,c^3,c^2,c,1]
[d^4,d^3,d^2,d,1]
[e^4,e^3,e^2,e,1]
ans=
(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;21-2-2];
J=jordan(A)
[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
100-2
14试用数值方法和解析方法求取下面的Sylvester方程,并验证得出的结果。
解:
A=[3,-6,-4,0,5;142-24;-63-673;-13100-110;04034];
B=[3-21;-2-92;-2-19];
C=[-21-1;412;5-61;6-4-4;-66-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=
3.4356e-13
15假设已知矩阵
如下,试求出
,
,
。
解:
A=[-4.500.5-1.5;-0.5-40.5-0.5;1.51-2.51.5;0-1-1-3];
A=sym(A);
symst;
exp(A*t)
sin(A*t)
exp(A*t)*sin(A^2*exp(A*t)*t)
ans=
[exp(-(9*t)/2),1,exp(t/2),exp(-(3*t)/2)]
[exp(-t/2),exp(-4*t),exp(t/2),exp(-t/2)]
[exp((3*t)/2),exp(t),exp(-(5*t)/2),exp((3*t)/2)]
[1,exp(-t),exp(-t),exp(-3*t)]
ans=
[-sin((9*t)/2),0,sin(t/2),-sin((3*t)/2)]
[-sin(t/2),-sin(4*t),sin(t/2),-sin(t/2)]
[sin((3*t)/2),sin(t),-sin((5*t)/2),sin((3*t)/2)]
[0,-sin(t),-sin(t),-sin(3*t)]
ans=
[sin(t*(17*exp(-t/2)-3*exp((3*t)/2)+5*exp(-(9*t)/2)+5))+exp(-(3*t)/2)*sin(t*(6*exp(-t/2)+5*exp((3*t)/2)-exp(-(9*t)/2)+8))-exp(t/2)*sin(t*(8*exp(-t/2)-6*exp((3*t)/2)+11*exp(-(9*t)/2)+11))+exp(-(9*t)/2)*sin(t*(2*exp(-t/2)-2*exp((3*t)/2)+21*exp(-(9*t)/2)+12)),sin(t*(5*exp(-t)+17*exp(-4*t)-3*exp(t)+5))+sin(t*(8*exp(-t)+6*exp(-4*t)+5*exp(t)-1))*exp(-(3*t)/2)-sin(t*(11*exp(-t)+8*exp(-4*t)-6*exp(t)+11))*exp(t/2)+sin(t*(12*exp(-t)+2*exp(-4*t)-2*exp(t)+21))*exp(-(9*t)/2),sin(t*(5*exp(-t)+22*exp(t/2)-3*exp(-(5*t)/2)))+exp(-(3*t)/2)*sin(t*(8*exp(-t)+5*exp(t/2)+5*exp(-(5*t)/2)))-exp(t/2)*sin(t*(11*exp(-t)+19*exp(t/2)-6*exp(-(5*t)/2)))+exp(-(9*t)/2)*sin(t*(12*exp(-t)+23*exp(t/2)-2*exp(-(5*t)/2))),sin(t*(5*exp(-3*t)+17*exp(-t/2)+5*exp(-(3*t)/2)-3*exp((3*t)/2)))+sin(t*(8*exp(-3*t)+6*exp(-t/2)-exp(-(3*t)/2)+5*exp((3*t)/2)))*exp(-(3*t)/2)-sin(t*(11*exp(-3*t)+8*exp(-t/2)+11*exp(-(3*t)/2)-6*exp((3*t)/2)))*exp(t/2)+sin(t*(12*exp(-3*t)+2*exp(-t/2)+21*exp(-(3*t)/2)-2*exp((3*t)/2)))*exp(-(9*t)/2)]
[exp(-t/2)*sin(t*(6*exp(-t/2)+5*exp((3*t)/2)-exp(-(9*t)/2)+8))+exp(-4*t)*sin(t*(17*exp(-t/2)-3*exp((3*t)/2)+5*exp(-(9*t)/2)+5))-exp(t/2)*sin(t*(8*exp(-t/2)-6*exp((3*t)/2)+11*exp(-(9*t)/2)+11))+exp(-t/2)*sin(t*(2*exp(-t/2)-2*exp((3*t)/2)+21*exp(-(9*t)/2)+12)),sin(t*(8*exp(-t)+6*exp(-4*t)+5*exp(t)-1))*exp(-t/2)+sin(t*(5*exp(-t)+17*exp(-4*t)-3*exp(t)+5))*exp(-4*t)-sin(t*(11*exp(-t)+8*exp(-4*t)-6*exp(t)+11))*exp(t/2)+sin(t*(12*exp(-t)+2*exp(-4*t)-2*exp(t)+21))*exp(-t/2),exp(-t/2)*sin(t*(8*exp(-t)+5*exp(t/2)+5*exp(-(5*t)/2)))+exp(-4*t)*sin(t*(5*exp(-t)+22*exp(t/2)-3*exp(-(5*t)/2)))-exp(t/2)*sin(t*(11*exp(-t)+19*exp(t/2)-6*exp(-(5*t)/2)))+exp(-t/2)*sin(t*(12*exp(-t)+23*exp(t/2)-2*exp(-(5*t)/2))),sin(t*(8*exp(-3*t)+6*exp(-t/2)-exp(-(3*t)/2)+5*exp((3*t)/2)))*exp(-t/2)+sin(t*(5*exp(-3*t)+17*exp(-t/2)+5*exp(-(3*t)/2)-3*exp((3*t)/2)))*exp(-4*t)-sin(t*(11*exp(-3*t)+8*exp(-t/2)+11*exp(-(3*t)/2)-6*exp((3*t)/2)))*exp(t/2)+sin(t*(12*exp(-3*t)+2*exp(-t/2)+21*exp(-(3*t)/2)-2*exp((3*t)/2)))*exp(-t/2)]
[exp((3*t)/2)*sin(t*(6*exp(-t/2)+5*exp((3*t)/2)-exp(-(9*t)/2)+8))+exp((3*t)/2)*sin(t*(2*exp(-t/2)-2*exp((3*t)/2)+21*exp(-(9*t)/2)+12))-exp(-(5*t)/2)*sin(t*(8*exp(-t/2)-6*exp((3*t)/2)+11*exp(-(9*t)/2)+11))+exp(t)*sin(t*(17*exp(-t/2)-3*exp((3*t)/2)+5*exp(-(9*t)/2)+5)),sin(t*(5*exp(-t)+17*exp(-4*t)-3*exp(t)+5))*exp(t)+sin(t*(8*exp(-t)+6*exp(-4*t)+5*exp(t)-1))*exp((3*t)/2)+sin(t*(12*exp(-t)+2*exp(-4*t)-2*exp(t)+21))*exp((3*t)/2)-sin(t*(11*exp(-t)+8*exp(-4*t)-6*exp(t)+11))*exp(-(5*t)/2),exp((3*t)/2)*sin(t*(8*exp(-t)+5*exp(t/2)+5*exp(-(5*t)/2)))+exp((3*t)/2)*sin(t*(12*exp(-t)+23*exp(t/2)-2*exp(-(5*t)/2)))-exp(-(5*t)/2)*sin(t*(11*exp(-t)+19*exp(t/2)-6*exp(-(5*t)/2)))+exp(t)*sin(t*(5*exp(-t)+22*exp(t/2)-3*exp(-(5*t)/2))),sin(t*(5*exp(-3*t)+17*exp(-t/2)+5*exp(-(3*t)/2)-3*exp((3*t)/2)))*exp(t)+sin(t*(8*exp(-3*t)+6*exp(-t/2)-exp(-(3*t)/2)+5*exp((3*t)/2)))*exp((3*t)/2)+sin(t*(12*exp(-3*t)+2*exp(-t/2)+21*exp(-(3*t)/2)-2*exp((3*t)/2)))*exp((3*t)/2)-sin(t*(11*exp(-3*t)+8*exp(-t/2)+11*exp(-(3*t)/2)-6*exp((3*t)/2)))*exp(-(5*t)/2)]
[sin(t*(2*exp(-t/2)-2*exp((3*t)/2)+21*exp(-(9*t)/2)+12))+exp(-3*t)*sin(t*(6*exp(-t/2)+5*exp((3*t)/2)-exp(-(9*t)/2)+8))+exp(-t)*sin(t*(17*exp(-t/2)-3*exp((3*t)/2)+5*exp(-(9*t)/2)+5))-exp(-t)*sin(t*(8*exp(-t/2)-6*exp((3*t)/2)+11*exp(-(9*t)/2)+11)),sin(t*(12*exp(-t)+2*exp(-4*t)-2*exp(t)+21))+sin(t*(8*exp(-t)+6*exp(-4*t)+5*exp(t)-1))*exp(-3*t)+sin(t*(5*exp(-t)+17*exp(-4*t)-3*exp(t)+5))*exp(-t)-sin(t*(11*exp(-t)+8*exp(-4*t)-6*exp(t)+11))*exp(-t),sin(t*(12*exp(-t)+23*exp(t/2)-2*exp(-(5*t)/2)))+exp(-3*t)*sin(t*(8*exp(-t)+5*exp(t/2)+5*exp(-(5*t)/2)))+exp(-t)*sin(t*(5*exp(-t)+22*exp(t/2)-3*exp(-(5*t)/2)))-exp(-t)*sin(t*(11*exp(-t)+19*exp(t/2)-6*exp(-(5*t)/2))),sin(t*(12*exp(-3*t)+2*exp(-t/2)+21*exp(-(3*t)/2)-2*exp((3*t)/2)))+sin(t*(8*exp(-3*t)+6*exp(-t/2)-exp(-(3*t)/2)+5*exp((3*t)/2)))*exp(-3*t)+sin(t*(5*exp(-3*t)+17*exp(-t/2)+5*exp(-(3*t)/2)-3*exp((3*t)/2)))*exp(-t)-sin(t*(11*exp(-3*t)+8*exp(-t/2)+11*exp(-(3*t)/2)-6*exp((3*t)/2)))*exp(-t)]
第二部分数学问题求解与数据处理(4学时)
主要内容:
掌握代数方程与最优化问题、微分方程问题、数据处理问题的MATLAB求解方法。
练习题:
1、对下列的函数
进行Laplace变换。
(1)
;
(2)
;(3)
。
解:
(1)symsat;
f=sin(a*t)/t;
F=laplace(f)
F=atan(a/s)
(2)symsat;
f=t^5*sin(a*t);
F=laplace(f)
pretty(F)
720as3840as^33840as^5
------------------------------+---------------
(a^2+s^2)^4(a^2+s^2)^5(a^2+s^2)^6
(3)symsat;
f=t^8*cos(a*t);
F=laplace(f)
pretty(F)
3579
362880s4838400s17418240s23224320s10321920s
-----------------------------+---------------------------------+----------------
56789
#1#1#1#1#1
where
22
#1=a+s
2、对下面的
式进行Laplace反变换。
(1)
;
(2)
;(3)
。
解:
(1)symssab;
F=1/(sqrt(s^2)*(s^2-a^2)*(s+b));
Fa=ilaplace(F)
Fa=-ilaplace(1/((b+s)*(a^2-s^2)*(s^2)^(1/2)),s,t)
(2)symssab;
F=sqrt(s-a)-sqrt(s-b);
fb=ilaplace(F)
fb=ilaplace((s-a)^(1/2),s,t)-ilaplace((s-b)^(1/2),s,t)
(3)symssab;
F=log((s-a)/(s-b));
fc=ilaplace(F)
fc=exp(b*t)/t-exp(a*t)/t
3、试求出下面函数的Fourier变换,对得出的结果再进行Fourier反变换,观察是否能得出原来函数。
(1)
;
(2)
。
解:
(1)symsx;
f=x^2*(3*pi-2*abs(x));
F=fourier(f)
f1=ifourier(F)
F=-24/w^4-6*pi^2*dirac(w,2)
f1=(6*pi^2*x^2-4*pi*x^3*(2*heaviside(x)-1))/(2*pi)
(2)symst;
f=t^2*(t-2*pi)^2;
F=fourier(f)
f1=ifourier(F)
F=2*pi*dirac(w,4)+pi^2*dirac(w,3)*8*i-8*pi^3*dirac(w,2)
f1=(2*pi*x^4-8*pi^2*x^3+8*pi^3*x^2)/(2*pi)
4、请将下述时域序列函数
进行Z变换,并对结果进行反变换检验。
(1)
;
(2)
;(3)
。
解:
(1)symsakT;
f=cos(k*a*T);
F=ztrans(f)
f1=iztrans(F)
F=(z*(z-cos(T*a)))/(z^2-2*cos(T*a)*z+1)
f1=cos(n*acos(cos(T*a)))
(2)symsakT;
f=(k*T)^2*exp(-a*k*T);
F=ztrans(f)
fb=iztrans(F)
F=(T^