同济大学matlab课程练习题答案.docx

上传人:b****8 文档编号:27856303 上传时间:2023-07-05 格式:DOCX 页数:49 大小:27.59KB
下载 相关 举报
同济大学matlab课程练习题答案.docx_第1页
第1页 / 共49页
同济大学matlab课程练习题答案.docx_第2页
第2页 / 共49页
同济大学matlab课程练习题答案.docx_第3页
第3页 / 共49页
同济大学matlab课程练习题答案.docx_第4页
第4页 / 共49页
同济大学matlab课程练习题答案.docx_第5页
第5页 / 共49页
点击查看更多>>
下载资源
资源描述

同济大学matlab课程练习题答案.docx

《同济大学matlab课程练习题答案.docx》由会员分享,可在线阅读,更多相关《同济大学matlab课程练习题答案.docx(49页珍藏版)》请在冰豆网上搜索。

同济大学matlab课程练习题答案.docx

同济大学matlab课程练习题答案

同济大学matlab课程练习题答案

关晓飞

第一章初识matlab

题目1

x1=input('x1=');

x2=input('x2=');

x3=input('x3=');

x4=input('x4=');

x5=input('x5=');

x6=input('x6=');

x7=input('x7=');

a=x1/x5;

b=[x3/(x2-x1)]^0.85;

c=1-0.36*(x4/x2)^(-0.56);

d=2.62*c^1.5;

e=(x4/x2)^1.16;

f=[(1-d*e)/(x6*x7)]^0.5;

y=174.42*a*b*f

题目2

题目3

>>helplookfor

lookforSearchallMATLABfilesforkeyword.

lookforXYZlooksforthestringXYZinthefirstcommentline

(theH1line)oftheHELPtextinallMATLABfilesfoundonMATLABPATH

(includingprivatedirectories).Forallfilesinwhicha

matchoccurs,lookfordisplaystheH1line.

Forexample,"lookforinverse"findsatleastadozenmatches,

includingtheH1linescontaining"inversehyperboliccosine"

"two-dimensionalinverseFFT",and"pseudoinverse".

Contrastthiswith"whichinverse"or"whatinverse",whichrun

morequickly,butwhichprobablyfailtofindanythingbecause

MATLABdoesnotordinarilyhaveafunction"inverse".

lookforXYZ-allsearchestheentirefirstcommentblockof

eachMATLABfile.

Insummary,WHATliststhefunctionsinagivendirectory,

WHICHfindsthedirectorycontainingagivenfunctionorfile,and

lookforfindsallfunctionsinalldirectoriesthatmighthave

somethingtodowithagivenkeyword.

题目4

n=input('n=');

sum(1:

n)

prod(1:

n)

题目5

>>linspace(0,360,9)

ans=

04590135180225270315360

题目7

n=input('n=')

formatbank

n

第二章矩阵的建立

题目1.

spiral产生螺旋矩阵

例:

>>spiral(3)

ans=

  789

  612

  543

题目2.

(1)

[12;34]+10-2i

ans=

 11.0000-2.0000i 12.0000-2.0000i

 13.0000-2.0000i 14.0000-2.0000i

(2)

[12;34].*[0.10.2;0.30.4]

ans= 

  0.1000  0.4000

  0.9000  1.6000

(3)

[12;34].\[2010;92]

ans= 

  20.0000  5.0000

  3.0000  0.5000

(4)

exp([12;34]) %自然对数的1、2、3、4乘方

ans=

  2.7183  7.3891

  20.0855 54.5982

(5)

[12;34].^2

ans=

 

   1  4

   9  16

(6)

sum([12;34])      

 

ans=

 

   4  6

(7)

prod([12;34]) %每一列的所有行相加

 

ans=

 

   3  8

(8)

[a,b]=min([1020;3040]) %a代表每一列的最小值,b代表该值所在的行数

a=

 

  10  20

 

 

b=

 

   1  1

(9)

abs([12;34]-pi) %绝对值

 

ans=

 

  2.1416  1.1416

  0.1416  0.8584

(10)

linspace(3,4,5) %生成3到4均匀的5个数

 

ans=

 

  3.0000  3.2500  3.5000  3.7500  4.0000

(11)

A=[12;34];sort(A(:

2)) %提取第2列

 

ans=

 

   2

   4

 

题目3.

A=[1,2,3,4;4,3,2,1;2,3,4,1;3,2,4,1]

 

A=

   1  2  3  4

   4  3  2  1

   2  3  4  1

   3  2  4  1

 

A(5,6)=5 

A= 

   1  2  3  4  0  0

   4  3  2  1  0  0

   2  3  4  1  0  0

   3  2  4  1  0  0

   0  0  0  0  0  5

题目4

示例:

A=[3-1;-13] 

A= 

   3  -1

  -1  3 

[X,D]=eig(A)

X= 

  -0.7071 -0.7071

  -0.7071  0.7071 

D= 

   2  0

   0  4

题目5

A=

   3  -1

  -1  3 

2^A

ans= 

  10  -6

  -6  10 

2.^A

ans=

  8.0000  0.5000

  0.5000  8.0000

题目6

(1)

A=magic(6)

 

A=

  35  1  6  26  19  24

   3  32  7  21  23  25

  31  9  2  22  27  20

   8  28  33  17  10  15

  30  5  34  12  14  16

   4  36  29  13  18  11 

c=A(2,1)

c=

   3

(2)

t=2:

2:

6;

B=A(t,:

);

B

B=

   3  32  7  21  23  25

   8  28  33  17  10  15

   4  36  29  13  18  11

(3)

A(:

[end,2:

end-1,1]) 

ans=

  24  1  6  26  19  35

  25  32  7  21  23  3

  20  9  2  22  27  31

  15  28  33  17  10  8

  16  5  34  12  14  30

  11  36  29  13  18  4

(4)

A(:

[13456])

ans=

  35  6  26  19  24

   3  7  21  23  25

  31  2  22  27  20

   8  33  17  10  15

  30  34  12  14  16

   4  29  13  18  11

题目7

ones(4,5) 

ans=

   1  1  1  1  1

   1  1  1  1  1

   1  1  1  1  1

   1  1  1  1  1

 

rand(3,4)

ans=

  0.8147  0.9134  0.2785  0.9649

  0.9058  0.6324  0.5469  0.1576

  0.1270  0.0975  0.9575  0.9706

>>eye(3)

ans= 

   1  0  0

   0  1  0

   0  0  1

题目8

A=[0:

99];A=reshape(A,10,10)

 

A=

 

   0  10  20  30  40  50  60  70  80  90

   1  11  21  31  41  51  61  71  81  91

   2  12  22  32  42  52  62  72  82  92

   3  13  23  33  43  53  63  73  83  93

   4  14  24  34  44  54  64  74  84  94

   5  15  25  35  45  55  65  75  85  95

   6  16  26  36  46  56  66  76  86  96

   7  17  27  37  47  57  67  77  87  97

   8  18  28  38  48  58  68  78  88  98

   9  19  29  39  49  59  69  79  89  99

A=magic(3)

题目9

A=

 

   8  1  6

   3  5  7

   4  9  2

 

A(2,:

)=A(2,:

)*2

 

A=

 

   8  1  6

   6  10  14

   4  9  2

 

A(1,:

)=A(1,:

)+A(3,:

)*(-2)

 

A=

   0 -17  2

   6  10  14

   4  9  2

题目10

A=[1,3,5;5,8,3;6,1,6];B=[3,6;9,5;8,2];C=[3,3,9;4,0,6];D=[2:

6];

[A,B]

ans=

   1  3  5  3  6

   5  8  3  9  5

   6  1  6  8  2

[A;C]

ans= 

   1  3  5

   5  8  3

   6  1  6

   3  3  9

   4  0  6 

[A,B;D]

ans=

   1  3  5  3  6

   5  8  3  9  5

   6  1  6  8  2

   2  3  4  5  6

A=ones(6,7) 

A= 

   1  1  1  1  1  1  1

   1  1  1  1  1  1  1

   1  1  1  1  1  1  1

   1  1  1  1  1  1  1

   1  1  1  1  1  1  1

   1  1  1  1  1  1  1

题目11

fori=1:

6

forj=1:

7

A(i,j)=i+j;

end

end

A= 

   2  3  4  5  6  7  8

   3  4  5  6  7  8  9

   4  5  6  7  8  9  10

   5  6  7  8  9  10  11

   6  7  8  9  10  11  12

   7  8  9  10  11  12  13

%本题还有多种方法

第三章符号计算

题目1

题目2

>>sym('0,3')

ans=

0.3

>>sym(0.3)%符号工具箱得出更精确的解

ans=

3/10

题目3

>>symsxs

>>f=x^5+3*x^4+4*x^3+2*x^2+3*x+6;g=(s-1)/(s+1);

>>f(x)=compose(f,g,x,s)

f(x)=

(3*(s-1))/(s+1)+(2*(s-1)^2)/(s+1)^2+(4*(s-1)^3)/(s+1)^3+(3*(s-1)^4)/(s+1)^4+(s-1)^5/(s+1)^5+6

>>simplify(f(x))

ans=

19-(72*s^4+120*s^3+136*s^2+72*s+16)/(s+1)^5

题目4

>>sum(sym

(2).^[1:

64])

ans=

230

题目5

f=sym('cos(4*a)-4*cos(2*a)+3');simplify(f)

ans=

8*sin(a)^4

题目6

>>f=sym('(3*x+2/3)^10');expand(f)

ans=

59049*x^10+131220*x^9+131220*x^8+77760*x^7+30240*x^6+8064*x^5+(4480*x^4)/3+(5120*x^3)/27+(1280*x^2)/81+(5120*x)/6561+1024/59049

所以系数最大的项是131220*x^9和131220*x^8

题目7

>>symsax

>>factor(a*(sin(x))^2-(2*a^2-a+1)*sin(x)+2*a-1)

ans=

(sin(x)-2*a+1)*(a*sin(x)-1)

第四章极限与导数

题目1

(1)

>>symsx;lim1=limit([cos(x)-exp(-x^2/2)]/x^4,x,0)

 lim1=

 -1/12

(2)

>>symsxt;lim2=limit((1+2*t/x)^3*x,x,inf)

 lim2=

 Inf+imag(t)*6*i

(3)

>>symsx;lim3=limit(1/x,x,0,'right')

 Lim3=

Inf

(4)

>>symsx;lim4=limit((2^x-log(2^x)-1)/(1-cos(x)),x,0)

 Lim4=

log

(2)^2

题目2

>>symsx;lim=limit((exp(x)-1-x)/x^2,x,0)

 lim=

1/2

题目3

>>symsx;lim=limit(x^0.5-2^(-1/x),x,0,'right')

lim=

 0

题目4

>>symsx;lim=limit(atan(x)/(1+x^2),x,pi,'left')

 lim=

atan(pi)/(pi^2+1)

题目5

>>y=7*x^3-2*x+3;z=diff(y,2);x=1;eval(z)

ans=

 42

题目6

>>symsxy;z=exp(x)*sin(2*y)+log(x)*cos(2*y);f=diff(z,y)

f=

2*cos(2*y)*exp(x)-2*sin(2*y)*log(x)

题目7

>> symsxyt;x=t^2*sin(t);y=2*t*cos(t);f=diff(y)/diff(x)

f=

(2*cos(t)-2*t*sin(t))/(t^2*cos(t)+2*t*sin(t))

题目8

>>symsx;lim=limit((3^x+9^x)^(1/x),x,inf)

 lim=9

题目9

>> symsx;lim=limit((1+x)^(1/x),x,0)

lim=

 exp

(1)

题目10

>>symsx;y=[(x-1)*(x-2)/(x-3)/(x-4)]^0.5;f1=diff(y,1),f2=diff(y,2),f3=diff(y,3)

f1=

 ((x-1)/((x-3)*(x-4))+(x-2)/((x-3)*(x-4))-((x-1)*(x-2))/((x-3)*(x-4)^2)-((x-1)*(x-2))/((x-3)^2*(x-4)))/(2*(((x-1)*(x-2))/((x-3)*(x-4)))^(1/2))

  f2=

 (2/((x-3)*(x-4))-(2*(x-1))/((x-3)*(x-4)^2)-(2*(x-1))/((x-3)^2*(x-4))-(2*(x-2))/((x-3)*(x-4)^2)-(2*(x-2))/((x-3)^2*(x-4))+(2*(x-1)*(x-2))/((x-3)*(x-4)^3)+(2*(x-1)*(x-2))/((x-3)^2*(x-4)^2)+(2*(x-1)*(x-2))/((x-3)^3*(x-4)))/(2*(((x-1)*(x-2))/((x-3)*(x-4)))^(1/2))-((x-1)/((x-3)*(x-4))+(x-2)/((x-3)*(x-4))-((x-1)*(x-2))/((x-3)*(x-4)^2)-((x-1)*(x-2))/((x-3)^2*(x-4)))^2/(4*(((x-1)*(x-2))/((x-3)*(x-4)))^(3/2))

  f3=

 (3*((x-1)/((x-3)*(x-4))+(x-2)/((x-3)*(x-4))-((x-1)*(x-2))/((x-3)*(x-4)^2)-((x-1)*(x-2))/((x-3)^2*(x-4)))^3)/(8*(((x-1)*(x-2))/((x-3)*(x-4)))^(5/2))-(6/((x-3)*(x-4)^2)+6/((x-3)^2*(x-4))-(6*(x-1))/((x-3)*(x-4)^3)-(6*(x-1))/((x-3)^2*(x-4)^2)-(6*(x-1))/((x-3)^3*(x-4))-(6*(x-2))/((x-3)*(x-4)^3)-(6*(x-2))/((x-3)^2*(x-4)^2)-(6*(x-2))/((x-3)^3*(x-4))+(6*(x-1)*(x-2))/((x-3)*(x-4)^4)+(6*(x-1)*(x-2))/((x-3)^2*(x-4)^3)+(6*(x-1)*(x-2))/((x-3)^3*(x-4)^2)+(6*(x-1)*(x-2))/((x-3)^4*(x-4)))/(2*(((x-1)*(x-2))/((x-3)*(x-4)))^(1/2))-(3*((x-1)/((x-3)*(x-4))+(x-2)/((x-3)*(x-4))-((x-1)*(x-2))/((x-3)*(x-4)^2)-((x-1)*(x-2))/((x-3)^2*(x-4)))*(2/((x-3)*(x-4))-(2*(x-1))/((x-3)*(x-4)^2)-(2*(x-1))/((x-3)^2*(x-4))-(2*(x-2))/((x-

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

当前位置:首页 > 成人教育 > 成考

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

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