资源描述:
《同济大学matlab课程练习题答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、同济大学matlab课程练习题答案关晓飞第一章初识matlab题目1x1=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
2、*f题目2略题目3>>helplookforlookforSearchallMATLABfilesforkeyword.lookforXYZlooksforthestringXYZinthefirstcommentline(theH1line)oftheHELPtextinallMATLABfilesfoundonMATLABPATH(includingprivatedirectories).Forallfilesinwhichamatchoccurs,lookfordisplaystheH1line.Forexampl
3、e,"lookforinverse"findsatleastadozenmatches,includingtheH1linescontaining"inversehyperboliccosine""two-dimensionalinverseFFT",and"pseudoinverse".Contrastthiswith"whichinverse"or"whatinverse",whichrunmorequickly,butwhichprobablyfailtofindanythingbecauseMATLABdoesn
4、otordinarilyhaveafunction"inverse".lookforXYZ-allsearchestheentirefirstcommentblockofeachMATLABfile.Insummary,WHATliststhefunctionsinagivendirectory,WHICHfindsthedirectorycontainingagivenfunctionorfile,andlookforfindsallfunctionsinalldirectoriesthatmighthavesomet
5、hingtodowithagivenkeyword.题目4n=input('n=');sum(1:n)prod(1:n)题目5>>linspace(0,360,9)ans=04590135180225270315360题目7n=input('n=')formatbankn第二章矩阵的建立题目1.spiral产生螺旋矩阵例:>>spiral(3)ans= 789 612 543题目2.(1)[12;34]+10-2ians= 11.0000-2.0000i 12.0000-2.0000i 13.0000-2.0000
6、i 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].^2ans= 1 4 9 16(6)sum([12;34])
7、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(
8、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