东南大学matlab课程作业.docx

上传人:b****6 文档编号:8715495 上传时间:2023-05-14 格式:DOCX 页数:38 大小:129.51KB
下载 相关 举报
东南大学matlab课程作业.docx_第1页
第1页 / 共38页
东南大学matlab课程作业.docx_第2页
第2页 / 共38页
东南大学matlab课程作业.docx_第3页
第3页 / 共38页
东南大学matlab课程作业.docx_第4页
第4页 / 共38页
东南大学matlab课程作业.docx_第5页
第5页 / 共38页
东南大学matlab课程作业.docx_第6页
第6页 / 共38页
东南大学matlab课程作业.docx_第7页
第7页 / 共38页
东南大学matlab课程作业.docx_第8页
第8页 / 共38页
东南大学matlab课程作业.docx_第9页
第9页 / 共38页
东南大学matlab课程作业.docx_第10页
第10页 / 共38页
东南大学matlab课程作业.docx_第11页
第11页 / 共38页
东南大学matlab课程作业.docx_第12页
第12页 / 共38页
东南大学matlab课程作业.docx_第13页
第13页 / 共38页
东南大学matlab课程作业.docx_第14页
第14页 / 共38页
东南大学matlab课程作业.docx_第15页
第15页 / 共38页
东南大学matlab课程作业.docx_第16页
第16页 / 共38页
东南大学matlab课程作业.docx_第17页
第17页 / 共38页
东南大学matlab课程作业.docx_第18页
第18页 / 共38页
东南大学matlab课程作业.docx_第19页
第19页 / 共38页
东南大学matlab课程作业.docx_第20页
第20页 / 共38页
亲,该文档总共38页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

东南大学matlab课程作业.docx

《东南大学matlab课程作业.docx》由会员分享,可在线阅读,更多相关《东南大学matlab课程作业.docx(38页珍藏版)》请在冰点文库上搜索。

东南大学matlab课程作业.docx

东南大学matlab课程作业

MatlabWorksheet1

PartA

1.GetintoMatlab:

Usethediarycommandtorecordyouractivityintoafile:

diarymydiary01.docbeforeyoustartyourwork.(Anddiaryofftoswitchoffyourdiarywhenyoufinishyourwork.)

AttheCommandWindowassignavaluex=10,thenusetheUpKey↑torepeattheexpression,editingittoshowtheeffectofusingasemicolonafterthe10,namelyx=10;

Answers:

>> x=10 

 

x = 

 

    10 

 

>> x=10;

 

2.Confirmwhetherthefollowingnamesofvariablesareacceptable:

a)VelocityYesNo

b)Velocity1YesNo

c)Velocity.1YesNo

d)Velocity_1YesNo

e)Velocity-01YesNo

f)velocityONEYesNo

g)1velocityYesNo

3.Assigntwoscalarvariablesxandyvaluesx=1.5,y=2.3,thenconstructMatlabexpressionsforthefollowing:

a)

b)

c)

d)

Answers:

>>  x=1.5;y=2.3  

z1=5*x^3*y/(x+y) 

z2=(x^7*y^0.5)^(2/3) 

z3=(x^(1/6)/(log10(x^5-1))+1)*exp(-2*y) 

z4=sin(2*pi*x-y)+exp(x).*cos(2*pi*x)  

z1 = 

   10.2138 

z2 = 

    8.7566

z3 =

 0.0232  

z4 =  

   -3.7360 

4.Assigntwovariableswithcomplexvaluesu=2+3jandv=4+10jandthenconstructexpressionfor:

a)

b)

c)

d)

Answers:

>>  u=2+3j;v=4+10j; 

z1=u/v 

z2=u*v+2j 

z3=u/2j 

z4=v*exp(-j*2*pi*u)  

z1 =  

   0.3276 - 0.0690i  

z2 =

-22.0000 +34.0000i  

z3 =  

   1.5000 - 1.0000i  

z4 =  

   6.1421e+08 + 1.5355e+09i 

5.Usethecolonoperator:

toassignnumericalvaluesbetween0and1tovectorarrayvariableainstepsof0.1.

Answer:

>>  V=0:

0.1:

 

V = 

 

  Columns 1 through 10 

 

         0    0.1000    0.2000    0.3000    0.4000    0.5000    0.6000    0.7000    0.8000    

0.9000 

 

  Column 11 

 

    1.0000

 

 

6.Uselinspacefunctiontoassign20valuestovectorvariableybetween20and30.

Answer:

>> V=linspace(20,30,20) 

 

V = 

 

  Columns 1 through 10 

 

   20.0000   20.5263   21.0526   21.5789   22.1053   22.6316   23.1579   23.6842   

24.2105   24.7368 

 

  Columns 11 through 20 

 

   25.2632   25.7895   26.3158   26.8421   27.3684   27.8947   28.4211   28.9474   

29.4737   30.0000

 

7.Assign20valuestoavariablehincreasinglogarithmicallybetween10and1000.

Next,usethecolonoperatortoassignthefirst10elementsofhtoavariablep.

Answers:

>> v=logspace(1,3,20) 

 

v = 

 

   1.0e+03 * 

 

  Columns 1 through 10 

 

    0.0100    0.0127    0.0162    0.0207    0.0264    0.0336    0.0428    0.0546    

0.0695    0.0886 

 

  Columns 11 through 20 

 

0.1129    0.1438    0.1833    0.2336    0.2976    0.3793    0.4833    0.6158    

0.7848    1.0000 

>>  p=v(1:

10) 

 

p = 

10.0000   12.7427   16.2378   20.6914   26.3665   33.5982   42.8133   54.5559   69.5193   

88.5867

8.Create6elementrowvectorzwithvalues1.01.21.6-1.71.81.9,thenconstructanexpressionforthesumofthe2nd4thand6thelementsofz.

Answers:

>> z=[1.0  1.2  1.6  -1.7 1.8 1.9] 

x=z

(2)+z(4)+z(6) 

 

z = 

 

    1.0000    1.2000    1.6000   -1.7000    1.8000    1.9000 

 

 

x = 

 

    1.4000

9.Usethecolonoperatortocreateavectorarrayxbetween10and-10instepsof-1,andsecond,anarrayvectorybetween20and-20insteps-2.

a)Addxandy,b)subtract10xfrom5y.

Answers:

>>  x=10:

-1:

-10 

    y=20:

-2:

-20  

x =  

  Columns 1 through 17  

    10     9     8     7     6     5     4     3     2     1     0    -1    -2    -3    -4    -5    -6  

  Columns 18 through 21  

    -7    -8    -9   -10  

y =  

  Columns 1 through 17 

    20    18    16    14    12    10     8     6     4     2     0    -2    -4    -6    -8   -10   -12 

  Columns 18 through 21 

   -14   -16   -18   -20 

>> x+y  

ans =  

  Columns 1 through 17  

    30    27    24    21    18    15    12     9     6     3     0    -3    -6    -9   -12   -15   -18  

  Columns 18 through 21  

   -21   -24   -27   -30 

 

>> 5*y-10*x  

ans =  

  Columns 1 through 17  

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0  

  Columns 18 through 21 

     0     0     0     0

10.Usethesize,length,whoandwhoscommandstoestablishthesizeandlengthofxandyfromQuestion9,andusetransposeoperator’toconvertvectorxfromQuestion9.

Answers:

>> size(x) 

   length(x)  

ans =  

     1    21  

ans =  

    21 

>> who  

Your variables are:

  

ans  x    y      

>> whos 

  Name      Size            Bytes  Class     Attributes  

  ans       1x1                 8  double               

  x         1x21              168  double               

  y         1x21              168  double     

>> z=x' 

 

z =  

10 

     9 

     8 

     7 

     6 

     5 

     4 

     3 

     2 

     1 

     0 

    -1 

    -2 

    -3 

    -4 

    -5 

    -6 

    -7 

    -8 

    -9 

   -10

11.Showthatifw=[2i3i3+i]the.’operatorcreatesthetranspose.Whateffectdoestheoperator’appliedtowhaveonitsown?

Answer:

  >> w=[ 2i 3i 3+i] 

 

w = 

 

        0 + 2.0000i        0 + 3.0000i   3.0000 + 1.0000i 

 

>> x=w' 

 

x = 

 

        0 - 2.0000i 

        0 - 3.0000i 

   3.0000 - 1.0000i 

>> y=w.' 

 

y = 

 

        0 + 2.0000i 

        0 + 3.0000i 

   3.0000 + 1.0000i

12.Usetheonesfunctiontocreatea4by6arrayof1’s.Consideringjusttheshapeoftheresultingarray,whatdotheexpressionones(3),ones(5)andones(7)allhaveincommon?

Answer:

>> v=ones(4,6) 

 

v = 

 

     1     1     1     1     1     1 

     1     1     1     1     1     1 

     1     1     1     1     1     1 

     1     1     1     1     1     1 

>> ones(3) 

 

ans = 

 

     1     1     1 

     1     1     1 

     1     1     1 

 

>> ones(5) 

 

ans = 

 

     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 

Ones(n)是n阶全为1的方阵

 

13.Createusingtherandfunctiona5by4randommatrixandassignittomatrixarrayvariableAandobservecarefullywhatA(:

3)A(1:

2)andA(3,[24])mean.

Answer:

>> A=rand(5,4) 

 

A = 

 

    0.8147    0.0975    0.1576    0.1419 

    0.9058    0.2785    0.9706    0.4218 

    0.1270    0.5469    0.9572    0.9157 

    0.9134    0.9575    0.4854    0.7922 

    0.6324    0.9649    0.8003    0.9595 

 

>> A(:

3)  

 

ans = 

 

    0.1576 

    0.9706 

    0.9572 

    0.4854 

    0.8003 

 

>>  A(1:

2)  

 

ans = 

 

0.8147    0.9058 

>> A(3,[2 4])  

 

ans = 

 

    0.5469    0.9157

 

14.Usingarraysubscripts,createanexpressionforthesumoftheelementinthetopright-hand-cornerofAandthebottomleft-hand-cornerofA.Alsoassignthe2ndcolumnofAtoacolumnvectorb,andassignthe3rdrowofAtoarowvectord.

Answer:

>> A=rand(5,4) 

 

A = 

 

    0.7513    0.9593    0.8407    0.3500 

    0.2551    0.5472    0.2543    0.1966 

    0.5060    0.1386    0.8143    0.2511 

    0.6991    0.1493    0.2435    0.6160 

    0.8909    0.2575    0.9293    0.4733 

 

>> x=A(1,4)+A(4,1) 

 

x = 

 

1.0491 

>> b=A(:

2) 

 

b = 

 

    0.9593 

    0.5472 

    0.1386 

    0.1493 

    0.2575 

 

>> d=A(3,:

) 

 

d = 

 

    0.5060    0.1386    0.8143    0.2511

>>diaryofftoswitchoffyourdiarynow.

15.Usingthecolonoperator,assignarowvectorarrayt,valuesbetween0and10instepsof0.01.Usethe;operatortopreventdisplayingtheinformation.Obtaintheterm-by-termvaluesoffunctions:

a)

b)

c)

Answers:

    0.5874    0.6186    0.6473    0.6731    0.6958    0.7153    0.7314    0.7439    0.7528    

0.7581 

 

  Columns 551 through 560 

 

    0.7596    0.7573    0.7513    0.7417    0.7284    0.7117    0.6916    0.6684    0.6421    

0.6131 

 

  Columns 561 through 570 

 

    0.5815    0.5476    0.5117    0.4741    0.4350    0.3948    0.3538    0.3123    0.2706    

0.2291 

 

  Columns 571 through 580 

 

0.1880    0.1477    0.1085    0.0706    0.0344    0.0000   -0.0322   -0.0621  

-0.0895   -0.1141 

 

  Columns 581 through 590 

 

   -0.1359   -0.1548   -0.1705   -0.1832   -0.1928   -0.1992   -0.2025   -0.2027   -

0.2000   -0.1944 

 

  Columns 591 through 600 

 

   -0.1861   -0.1753   -0.1621   -0.1467   -0.1295   -0.1105   -0.0901   -0.0686   -

0.0462   -0.0232 

 

  Columns 601 through 610 

 

   -0.0000    0.0232    0.0461    0.0684    0.0898    0.1099    0.1287    0.1457    0.1608    

0.1737 

 

  Columns 611 through 620 

 

    0.1843    0.1923    0.1976    0.2001    0.1997    0.1962    0.1897    0.1801    0.1675    

0.1518 

 

  Columns 621 through 630 

 

    0.1332    0.1117    0.0875    0.0607    0.0315   -0.0000   -0.0335   -0.0687   -

0.1055   -0.1435 

 

  Columns 631 through 640 

 

   -0.1824   -0.2221   -0.2621   -0.3022   -0.3420   -0.3813   -0.4197   -0.4569   -

0.4927   -0.5267 

 

  Columns 641 through 650 

 

   -0.5587   -0.5885   -0.6157   -0.6403   -0.6619   -0.6804   -0.6957   -0.7076   -

0.7161   -0.7211 

 

  Columns 651 through 660 

 

   -0.7225   -0.7204   -0.7147   -0.7055   -0.6929   -0.6770   -0.6579   -0.6358   -

0.6108   -0.5832 

 

  Columns 661 through 670 

 

   -0.5532   -0.5209   -0.4868   -0.4510   -0.4138   -0.3756   -0.3366   -0.2971   -

0.2574   -0.2179 

 

  Columns 671 through 680 

 

   -0.1788   -0.1405 -0.1032 -0.0672-0.0327 -0.0000 0.0307 0.0591    

0.0851    0.1085 

 

  Columns 681 through 690 

 

    0.1293    0.1472    0.1622    0.1743    0.1834    0.1895    0.1926    0.1928    0.1902    

0.1849 

 

  Columns 691 through 700 

 

    0.1771    0.1667    0.1542    0.1396    0.1231    0.1051    0.0857    0.0652    0.0439    

0.0221 

 

  Columns 701 through 710 

 

    0.0000   -0.0221   -0.0439   -0.0650   -0.0854   -0.1046   -0.1224   -0.1386   -

0.1530   -0.1653 

 

  Columns 711 through 720 

 

   -0.1753   -0.1829   -0.1880   -0.1903   -0.1899 

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

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2