中南大matlab课后习题.docx

上传人:b****3 文档编号:26555361 上传时间:2023-06-20 格式:DOCX 页数:108 大小:2.79MB
下载 相关 举报
中南大matlab课后习题.docx_第1页
第1页 / 共108页
中南大matlab课后习题.docx_第2页
第2页 / 共108页
中南大matlab课后习题.docx_第3页
第3页 / 共108页
中南大matlab课后习题.docx_第4页
第4页 / 共108页
中南大matlab课后习题.docx_第5页
第5页 / 共108页
点击查看更多>>
下载资源
资源描述

中南大matlab课后习题.docx

《中南大matlab课后习题.docx》由会员分享,可在线阅读,更多相关《中南大matlab课后习题.docx(108页珍藏版)》请在冰豆网上搜索。

中南大matlab课后习题.docx

中南大matlab课后习题

第1章MATLAB操作基础

1MATLAB的主要功能包括数值计算和符号计算功能,绘图功能,编程语言以及应用工具箱。

2MATLAB的优点在于可以在窗口直接输入运算命令,并的到计算结果;有许多现成的函数可以直接调用;可以直接绘制图形对结果更直接的显示。

3MATLAB中help命令在窗口中输入后将会显示当前帮助系统中的所包含的所有项目,即搜索路径中所有的目录项目,所以可以搜索到。

4主要有控制系统工具箱,信号处理工具箱,神经网络工具箱,最优化工具箱,金融工具箱,统计学工具箱,功能性工具箱。

5inv为求方阵的逆矩阵,plot为对所给函数作图,max为取最大值,round为四舍五入到最临近的整数。

第2章MATLAB矩阵及其运算

2-1合法的变量有globalMy_expAbCdAB_C_

2-2直接输入法;利用M文件建立;利用冒号表达式建立一个向量;建立大矩阵。

2-3A*B要求A阵的列数必须与B阵的行数相等,A.*B表示对应元素相乘,矩阵运算左除与右除值一般不同,点除也有类似的规律,但对于标量则都相同。

2-4

(1)a=3.5;b=5;c=-9.8;

x=(2*pi+(b+c)/(pi+a*b*c)-exp

(2))/tan(b+c)+a

x=3.4054

(2)w=sqrt

(2)*(1+0.34245e-6)

w=1.4142

(3)t=[21-3i;5-0.65];

z=(exp(2*t)*log(t+sqrt(1+t^2)))/2

z=

1.0e+004*

0.0057-0.0007i0.0049-0.0027i

1.9884-0.3696i1.7706-1.0539i

2-5A=[-1,5,-4;0,7,8;3,61,7];

B=[8,3,-1;2,5,3;-3,2,0];

>>A+6*B

ans=

4723-10

123726

-15737

>>I=eye;

>>A^2-B+I

ans=

-18-21618

23533110

22868526

>>A*B

ans=

141416

-105121

125328180

>>A.*B

ans=

-8154

03524

-91220

>>B*A

ans=

-110-15

722853

3-128

>>A/B

ans=

1.2234-0.92552.9787

-0.94682.3511-0.9574

4.61703.872313.8936

>>B\A

ans=

-0.5106-8.6170-1.1277

0.734017.57451.8085

-0.8830-21.21280.4043

>>[A,B]

ans=

-15-483-1

078253

3617-320

2-6A=[23,10,-0.778,0;41,-45,65,5;32,5,0,32;6,-9.54,54,3.14];

B=A(1:

3,:

B=

23.000010.0000-0.77800

41.0000-45.000065.00005.0000

32.00005.0000032.0000

C=A(:

1:

2)

C=

23.000010.0000

41.0000-45.0000

32.00005.0000

6.0000-9.5400

D=A(2:

end,3:

end)

D=

65.00005.0000

032.0000

54.00003.1400

E=B*C

E=

1.0e+003*

0.9141-0.2239

1.20802.7123

1.1330-0.2103

E

ans=

01

00

01

>>E&D

ans=

11

01

11

>>E|D,~E|

ans=

11

11

11

~D

ans=

00

10

00

>>find(A>=10&A<=25)

ans=

1

5

2-7>>A=[34,NaN,Inf,-Inf,-pi,eps,0]

A=

34.0000NaNInf-Inf-3.14160.00000

>>all(A)

ans=0

>>any(A)

ans=1

>>isnan(A)

ans=0100000

>>isinf(A)

ans=0011000

>>isfinite(A)

ans=1000111

2-8>>A=[1-123;51-42;3052;111509];

>>diag(A)

ans=

1

1

5

9

>>triu(A)

ans=

1-123

01-42

0052

0009

>>tril(A)

ans=

1000

5100

3050

111509

>>inv(A)

ans=

-0.17580.16410.2016-0.0227

-0.1055-0.1016-0.03910.0664

-0.0508-0.08590.15160.0023

0.3906-0.0313-0.18130.0281

>>det(A)

ans=1280

>>rank(A)

ans=4

>>trace(A)

ans=16

>>norm(A,2)

ans=21.3005

>>norm(A,1)

ans=20

>>norm(A,inf)

ans=35

>>cond(A,1)

ans=14.4531

>>cond(A,2)

ans=11.1739

>>cond(A,inf)

ans=22.0938

>>B=[0.43432;-8.9421];

>>diag(B)

ans=0.4300

4.0000

>>triu(B)

ans=

0.430043.00002.0000

04.000021.0000

>>tril(B)

ans=

0.430000

-8.90004.00000

>>pinv(B)

ans=

0.0022-0.0175

0.0234-0.0017

-0.00350.0405

>>rank(B)

ans=2

>>trace(B)

ans=4.4300

>>norm(B,1)

ans=47

>>norm(B,2)

ans=43.4271

>>norm(B,inf)

ans=45.4300

2-9formatrat

>>h=hilb(5)

h=

11/21/31/41/5

1/21/31/41/51/6

1/31/41/51/61/7

1/41/51/61/71/8

1/51/61/71/81/9

>>Hh=det(h)

Hh=1/266716800000

>>Th=cond(h)

Th=476607

>>p=pascal(6)

p=

111111

123456

136101521

1410203556

15153570126

162156126252>>Hp=det(p)

Hp=1

>>Tp=cond(p)

Tp=332360/3

从矩阵的分析可以看出帕斯卡矩阵的性能要比希尔伯特矩阵的好。

2-10>>A=[-29618;20512;-885];

>>[V,D]=eig(A)

V=698/979395/1409989/3619

-859/1412-2430/3089349/400

538/1543423/769578/1427

D=-3595/14200

0-3755/3570

004697/279

A是n阶方阵,若有数λ和非零向量X,使得

AX=λX则称数λ是A的特征值,非零向量X是A对应于特征值λ的特征向量。

2-11其中6+7i表示一个复数,而6+7*i则表示一个表达式,i是虚数单位,I为一个变量。

2-12

(1)A(7)=[]

(2)t(find(t==0))=eps

(3)x=reshape(x,3,4)(4)abs(‘djdfsfksf”)(5)size(A)ones(x,y)(6)B=diag(A)

2-12A=3+randn([500,1])

2-13结构矩阵的建立具体格式为结构矩阵名.成员名=表达式;

单元矩阵的建立与结构矩阵的建立基本相同只是用大括号把矩阵元素括起来。

2-14稀疏矩阵可以有效的节省存储空间,稀疏矩阵与完全矩阵不同它有独特的调用方式。

第三章MATLAB程序设计

3-1n=input('请输入一个三位数:

');

a=fix(n/100);

b=rem(fix(n/10),10);

c=rem(n,10);

m=c*100+b*10+a;

disp(m)

3-2用if语句实现s=input('请输入成绩:

');

ifs>=90&c<=10

disp('A');

elseifs>=8&s<=89

disp('B');

elseifs>=70&s<=79

disp('C');

elseifs>=6&s<=69

disp('D');

elseifs>=0&s<=59

disp('E')

else

disp('false')

end

用switch语句实现

score=input('socre:

');

switchfix(score/10)

case{10,9}

disp('A');

case{8}

disp('B');

case{7}

disp('C');

case{6}

disp('D');

case(0:

5)

disp('E');

otherwise

disp('false')

end

3-3A=input('pleaseenterA:

');

min=A

(1);

max=A

(1);

fori=1:

19;

ifA(i+1)>max

max=A(i+1);

end

ifA(i+1)

min=A(i+1);

end

end

disp(max)

disp(min)

3-4顺序结构

a=input('pleaseinputa:

')

y=0.5*(exp(0.3*a)-exp(-0.3*a))*sin(a+0.3)+log(0.5*(0.3+a))

disp(y)

循环结构

fora=-3.0:

0.1:

3.0

y=0.5*(exp(0.3*a)-exp(-0.3*a))*sin(a+0.3)+log(0.5*(0.3+a))

disp(y)

end

3-5

(1)sum=0;

i=0;

n=input('entern:

')

whilei<=n

i=i+1;

sum=sum+1/i^2;

end

sum

(2)sum=0;

i=0;

n=input('entern:

')

forn=0:

1:

n

sum=sum*((2*n*2*n)/((2*n-1)*(2*n+1)));

end

sum

3-6A=[1,1,1,1,1,1;2,2,2,2,2,2;3,3,3,3,3,3;4,4,4,4,4,4;5,5,5,5,5,5;6,6,6,6,6,6];

n=input('请输入n的值:

');

ifn<=5&n>=0

disp(A([n],:

));

elseifn<0

disp(lasterr);

elsedisp(A([6],:

));

disp(lasterr);

end

3-7

(1)f=[];

forn=1:

40

f(n)=n+10*log(n^2+5);

end

y=f(40)/(f(30)+f(20))

(2)f=[];a=0;

forn=1:

40

f(n)=a+n*(n+1);

a=f(n);

end

y=f(40)/(f(30)+f(20))

3-8y=0;

函数文件

functions=ss(n,m)

s=0;

fori=1:

n

s=s+i^m;

end

命令文件

ss(100,1)+ss(50,2)+ss(10,1/2)

思考练习

3-1

M文件是指用MATLAB语言编写的程序。

建立一个M文件可以在主菜单File选项中的New选项中选择M-File建立;也可以在命令窗口中输入Edit建立;可以按命令按钮NewM-File建立。

执行时只需要在Debug中SaveAndRun。

3-2

N=[1,2,3,4,5];

2.*N

N./2

1./N

1./N.^2

3-3

s=fix(100*rand(1,20)*9/10+10)

y=sum(s)/20

j=0;

fori=1:

20

ifs(i)

j=j+1;

A(j)=s(i);

elsecontinue;

end

end

A

3-4

y1=0;y2=0;

n=input('请输入n的值:

');

fori=1:

n

y1=y1+-(-1)^i/(2*i-1);

y2=y2+1/4^i;

end

y1

y2

3-5

x=input('pleaseenterx:

');

a=exp(x);

b=log(x);

c=sin(x);

d=cos(x)

abcd

3-6

A=[1234;5678];

B=[2345;4321];

N=A.*B

第四章

一、实验内容

1.绘制曲线:

(1)y=x-x^3/3!

(2)x^2+2y^2=64

答案一:

答案二:

将原式转化成x=8cost;y=4*2^0.5sint

2.设y=1/(1+e^(-t)),-pi≤t≤pi,在同一图形窗口绘制条形图、杆图、和对数坐标图等不同图形,并对不同图形加标注说明。

3.绘制下列极坐标图

(1)Ρ=5cosφ+4

(2)Γ=5(sinφ)^2/cosφ-pi/3≤φ≤pi/3

第一题答案

第二题答案

4.绘制下列三维图形

(1)x=e^(-t/20)*costy=e^(-t/20)*sintz=t0≤t≤2pi

(2)z=5-5≤x≤5-5≤y≤5

要求应用差值着色处理。

第一题答案:

第二题答案:

5.播放一个直径不断变换的球体

二、思考练习

1,绘制下列曲线

(1)y=(1/2pi)*e^(-(x^2/2))

(2)x=tsinty=tcost

第一题答案

第二题答案

2,在同一坐标轴中绘制下列两条曲线并标注两曲线交叉点。

(1)y=2x-0.5

(2)x=sin(3t)costy=sin(3t)sint0≤t≤pi

3,分别用ploi和fplot函数绘制函数y=sin(1/x)的曲线,分析两曲线的差别。

4,绘制下列极坐标图。

(1)p=12/φ^0.5

(2)λ=(3asinφcosφ)/((sinφ)^3)+(cosφ)^3)-pi/6≤φ≤pi/6

第一题答案

第二题答案

5,绘制曲面图形

(1)x=3usinvy=2ucosvz=4u^2

(2)f(x,y)=-5/(1+x^2+y^2)-3≤x≤3-3≤y≤3

第一题答案

第二题答案

附:

程序代码

实验指导

1

(1)

x=-10:

0.05:

10;

y=x-x.^3./6;

plot(x,y)

(2)

x=-10:

0.5:

10;

ezplot('x^2+2*y^2-64',[-8,8]);

gridon;

2

t=-pi:

pi/10:

pi;

y=1./(1+exp(-t));

subplot(2,2,1);

bar(t,y);

title('条形图(t,y)');

axis([-pi,pi,0,1]);

subplot(2,2,2);

stairs(t,y,'b');

title('阶梯图(t,y)');

axis([-pi,pi,0,1]);

subplot(2,2,3);

stem(t,y,'k');

title('杆图(t,y)');

axis([-pi,pi,0,1]);

subplot(2,2,4);

loglog(t,y,'y');

title('对数坐标图(t,y)');

3

(1)

t=0:

pi/50:

2*pi;

r=5.*cos(t)+4;

polar(t,r);

title('\rho=5*cos\theta+4');

(2)

t=-pi/3:

pi/50:

pi/3;

r=5.*((sin(t)).^2)./cos(t);

polar(t,r);

4

(1)

t=0:

pi/50:

2*pi;

x=exp(-t./20).*cos(t);

y=exp(-t./20).*sin(t);

z=t;

plot3(x,y,z);

gridon;

(2)

[x,y]=meshgrid(-5:

5);

z=zeros(11)+5;

mesh(x,y,z);

shadinginterp;

5

[x,y,z]=sphere(20);

surf(x,y,z);

axisoff;

shadinginterp;

m=moviein(20);

fori=1:

20

axis([-i,i,-i,i,-i,i])

m(:

i)=getframe;

endmovie(m,4);

思考练习

2

(1)

x=-5:

0.1:

5;

y=(1./(2*pi)).*exp((-(x.^2))/2);

plot(x,y);

(2)

t=-2*pi:

0.1:

2*pi;

x=t.*sin(t);

y=t.*cos(t);

plot(x,y);

gridon;

3

t=0:

pi/1000:

pi;

x=sin(3.*t).*cos(t);

y1=sin(3.*t).*sin(t);

y2=2.*x-0.5;

plot(x,y1,'k',x,y2);

holdon;

k=find(abs(y1-y2)<1e-2);

x1=x(k);

y3=2.*x1-0.5;

plot(x1,y3,'rp');

4

x=-2:

0.01:

2;

y=sin(1./x);

subplot(2,1,1);

plot(x,y);

subplot(2,1,2);

fplot('sin(1./x)',[-2,2],1e-4);

5

(1)

i=-4*pi:

0.1:

10;

j=12./sqrt(i);

polar(i,j);

title('{\rho}=12/sqrt(\theta)')

(2)

a=-pi/6:

0.01:

pi/6;

b=3.*asin(a).*cos(a)./((sin(a)).^3+(cos(a)).^3);

polar(a,b);

6

(1)

[u,v]=meshgrid(-4:

0.1:

4);

x=3.*u.*sin(v);

y=2.*u.*cos(v);

z=4.*u.^2;subplot(2,1,1);

mesh(x,y,z);

subplot(2,1,2);

surf(x,y,z);

(2)

[x,y]=meshgrid(-3:

0.2:

3);

z=-5./(1+x.^2+y.^2);

subplot(1,2,1);

mesh(x,y,z);

subplot(1,2,2);

surf(x,y,z);

第五章

实验指导

第1题

>>A=randn(10,5)

A=

-0.4326-0.18670.2944-0.3999-1.6041

-1.66560.7258-1.33620.69000.2573

0.1253-0.58830.71430.8156-1.0565

0.28772.18321.62360.71191.4151

-1.1465-0.1364-0.69181.2902-0.8051

1.19090.11390.85800.66860.5287

1.18921.06681.25401.19080.2193

-0.03760.0593-1.5937-1.2025-0.9219

0.3273-0.0956-1.4410-0.0198-2.1707

0.1746-0.83230.5711-0.1567-0.0592

(1)>>M=mean(A)

M=

0.00130.23100.02530.3588-0.4197

D=std(A,0,1)

D=

0.90340.88291.18980.78321.0821

(2)>>max(max(A))

ans=

2.1832

>>min(min(A))

ans=

-2.1707

(3)>>X=sum(A,2)

X=

-2.3288

-1.3287

0.0105

6.2215

-1.4895

3.3602

4.9201

-3.6964

-3.3998

-0.3025

>>Y=sum(X)

Y=

1.9666

(4)>>B=sort(A)

B=

-1.6656-0.8323-1.5937-1.2025-2.1707

-1.1465-0.5883-1.4410-0.3999-1.6041

-0.4326-0.1867-1.3362-0.1567-1.0565

-0.0376-0.1364-0.6918-0.0198-0.9219

0.1253-0.09560.29440.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1