控制系統(tǒng)與仿真_第1頁
控制系統(tǒng)與仿真_第2頁
控制系統(tǒng)與仿真_第3頁
控制系統(tǒng)與仿真_第4頁
控制系統(tǒng)與仿真_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、 實驗一Matlab的基本操作一、驗證所有例題內容例1.1:Time=111212345678910Time=111212345678910X_Data=2.323.43;4.375.98X_Data=2.32003.43004.37005.9800例1.2:g=1234;h=4321;s1=g+h,s2=g.*h,s3=g.Ah,s4=g.A2,s5=2.Ahs1=5555s2=4664s3=1894s4=14916s5=16842例1.3:A=20-1;132;B=17-1;423;201;M=A*B14-31713100.10000.1500-0.3500-0.20000.7000-1.

2、3000V,D=eig(B)V=-0.7094+0.0000i0.7444+0.0000i0.7444+0.0000i-0.6675+0.0000i-0.3599+0.0218i-0.3599-0.0218i-0.2263+0.0000i-0.5587-0.0607i-0.5587+0.0607iD=7.2680+0.0000i0.0000+0.0000i0.0000+0.0000i0.0000+0.0000i-1.6340+0.2861i0.0000+0.0000i0.0000+0.0000i0.0000+0.0000i-1.6340-0.2861iX=A/BX=0.4000-1.40003

3、.600001.5000-2.5000Y=BAY=-0.95001.35000.5500-0.15000.9000-0.7000-0.35001.1500det_B=det(B)det_B=20rank_A=rank(A)rank_A=2inv_B=inv(B)inv_B=0.10003、輸入A=715;256;315,B=111;222;333,在命令窗口中執(zhí)行下列表達式,掌握其含義:A(2,3)%矩陣A第一行第三列的兀素A(:,2)%矩陣A第一列的數(shù)據(jù)A(3,:)%矩陣A第一行的數(shù)據(jù)A(:,1:2:3)%矩陣A第一列和第三列的數(shù)據(jù)A(:,3).*B(:,2)%矩陣A的第三列和矩陣B的第二列

4、點乘A(:,3)*B(2,:)%矩陣A的第三列和矩陣B的第二行相乘A*B%矩陣A和矩陣B相乘A*B%矩陣A和矩陣B點乘AA2%矩陣A的乘方AH2%矩陣A的點乘方B/A%矩陣B右除矩陣AB/A%矩陣B點除矩陣AA=715;256;315;B=111;222;333;A(2,3)ans=6A(:,2)ans=151A(3,:)TOC o 1-5 h zans=315A(:,1:2:3)ans=752635A(:,3).*B(:,2)ans=51215A(:,3)*B(2,:)ans=101010121212101010A*Bans=242424303030202020A.*Bans=7154101

5、29315AA2ans=661766423370381346A42ans=49125425369125B/Aans=0.18420.2105-0.23680.36840.4211-0.47370.55260.6316-0.7105B./Aans=0.14291.00000.20001.00000.40000.33331.00003.00000.60004、輸入C=1:2:20,則C(i)表示什么?其中i=l,2,3,;10C=1:2:20C=135791113151719C(i)下標索引必須為正整數(shù)類型或邏輯類型。c(l)ans=1C(2)ans=3C(3)ans=5C(4)ans=7C(5)

6、ans=9C(6)ans=11C(7)ans=13C(8)ans=15C(9)ans=17C(10)ans=195、先求下列表達式的值,然后顯示Matlab工作空間的使用情況并保存全部變量。(1)_2sin8511+e2。(2)其中x1z=ln(x+i1+x2),22e0.3ae-0.3aa+0.3(3)z=sin(a+0.3)+ln,a=3.0,2.9,2.8,.,2.8,2.9,3.0322提示:利用冒號表達式生成a向量,求各點的函數(shù)值時用點乘運算。zl=2*sin(85/360)/(l+(exp(l)人2)zl=0.0558x=21+2*i;-0.455x=2.0000+O.OOOOi1

7、.0000+2.0000i-0.4500+0.0000i5.0000+0.0000iz2=(log(x+sqrt(1+xA2)/2z2=0.7114-0.0253i0.8968+0.3658i0.2139+0.9343i1.1541-0.0044ia=-3:0.1:3a=Columns1through9-3.0000-2.9000-2.8000-2.7000-2.6000-2.5000-2.4000-2.3000-2.2000Columns10through18-2.1000-2.0000-1.9000-1.8000-1.7000-1.6000-1.5000-1.4000-1.3000Colu

8、mns19through27-1.2000-1.1000-1.0000-0.9000-0.8000-0.7000-0.6000-0.5000-0.4000Columns28through36-0.3000-0.2000-0.100000.10000.20000.30000.40000.5000Columns37through450.60000.70000.80000.90001.00001.10001.20001.30001.4000Columns46through541.50001.60001.70001.80001.90002.00002.10002.20002.3000Columns55

9、through612.40002.50002.60002.70002.80002.90003.0000m1=linspace(0.3,0.3,61)m1=Columns1through90.30000.30000.30000.30000.30000.30000.30000.30000.3000Columns10through180.30000.30000.30000.30000.30000.30000.30000.30000.3000Columns19through270.30000.30000.30000.30000.30000.30000.30000.30000.3000Columns28

10、through360.30000.30000.30000.30000.30000.30000.30000.30000.3000Columns37through450.30000.30000.30000.30000.30000.30000.30000.30000.3000Columns46through540.30000.30000.30000.30000.30000.30000.30000.30000.3000Columns55through610.30000.30000.30000.30000.30000.30000.3000m2=linspace(-0.3,-0.3,61)m2=Colum

11、ns1through9-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000Columns10through18-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000Columns19through27-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000Columns28through36-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3

12、000-0.3000-0.3000Columns37through45-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000Columns46through54-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000Columns55through61-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000-0.3000z2=(power(exp(l),ml.*a)-power(exp(l),m2.*a)/2.*sin(a+m

13、l)+log(a+ml)/2)z2=Columnslthrough40.7388+3.1416i0.7696+3.1416iColumns5through80.7822+3.1416i0.7602+3.1416iColumns9through120.6196+3.1416i0.5496+3.1416iColumns13through160.2775+3.1416i0.1680+3.1416iColumns17through20-0.2124+3.1416i-0.3566+3.1416iColumns21through24-0.8536+3.1416i-1.0497+3.1416iColumns

14、25through28-1.8436+3.1416i-2.2727+3.1416iColumns29through32-3.0017+0.0000i-2.3085+0.0000iColumns33through36-1.3575+0.0000i-1.1531+0.0000iColumns37through40-0.6567+0.0000i-0.5151+0.0000iColumns41through44-0.1374+0.0000i-0.0255+0.0000iColumns45through480.2663+0.0000i0.3478+0.0000iColumns49through520.5

15、379+0.0000i0.5815+0.0000iColumns53through560.6474+0.0000i0.6470+0.0000iColumns57through600.5777+0.0000i0.5327+0.0000iColumn610.3388+0.0000i0.7871+3.1416i0.7913+3.1416i0.7254+3.1416i0.6784+3.1416i0.4688+3.1416i0.3780+3.1416i0.0497+3.1416i-0.0771+3.1416i-0.5104+3.1416i-0.6752+3.1416i-1.2701+3.1416i-1.

16、5271+3.1416i-2.9837+3.1416i-37.0245+0.0000i-1.8971+0.0000i-1.5978+0.0000i-0.9723+0.0000i-0.8083+0.0000i-0.3819+0.0000i-0.2561+0.0000i0.0792+0.0000i0.1766+0.0000i0.4206+0.0000i0.4841+0.0000i0.6145+0.0000i0.6366+0.0000i0.6351+0.0000i0.6119+0.0000i0.4774+0.0000i0.4126+0.0000ii234-4_13-1A=34787,B=203365

17、73-276、已知:求下列表達式的值。A+6*B和A一B+八其中I為單位矩陣;A*B和A.*BA人3和A.人3A/B和ABA,B和A(1,3,:);BA2A=1234-4;34787;3657;B=13-1;203;3-27;A+6*Bans=1852-10467105215349I=eye(3);A-B+Ians=1231-3328840i671A*Bans=684462309-72596154-5241A.*Bans=12:0246802619-13049AA3ans=372262338244860424737014918860076678688454142118820A.A3ans=17

18、2839304-643930434365850327274625343A/Bans=16.4000-13.60007.600035.8000-76.200050.200067.0000-134.000068.0000ABans=-0.03130.3029-0.33240.0442-0.03230.10630.0317-0.11580.1558A,Bans=1234-413-13478720336573-27A(1,3,:);B9ans=1234-436574511101920-540實驗二Matlab的數(shù)值計算和符號運算一上機驗證實驗A、開啟PC機,進入MATLAB語言B、幫助命令的使用,査找

19、sqrt函數(shù)的使用方法答:helpsqrtsqrt-SquarerootThisMATLABfunctionreturnsthesquarerootofeachelementofthearrayX.B=sqrt(X)C、矩陣運算已知A=12;34;B=55;78;求AA2*B答:ans=105115229251矩陣除法。已知A=123;456;789;B=100;020;003;求A/B,AB答:A=123;456;789;B=100;020;003;A/Bans=1.00001.00001.00004.00002.50002.00007.00004.00003.0000AB警告:矩陣接近奇異

20、值,或者縮放錯誤。結果可能不準確。RCOND=1.541976e-18。ans=1.0e+16*-0.45041.8014-1.35110.9007-3.60292.7022-0.45041.8014-1.3511(3)矩陣的轉置及共軛轉置。已知A=15+i,2-i,1;6*i,4,9-i逑A,A答:A=15+i,2-i,l;6*i,4,9-i;A.ans=15.0000+l.OOOOi0.0000+6.0000i2.0000-1.0000i4.0000+0.0000i1.0000+0.0000i9.0000-1.0000iAans=15.0000-1.0000i0.0000-6.0000i2

21、.0000+1.0000i4.0000+0.0000i1.0000+0.0000i9.0000+1.0000i(4)使用冒號選出指定元素。已知A=123;456;789;求A中第3列前2個元素;A中所有第2行的元素;答:A=123;456;789;A(1:2,3)ans=36A(2,1:3)ans=456(5)方括號。用magic函數(shù)生成一個4階魔術矩陣,刪除該矩陣的第四列。答:A=magic(4)A=16231351110897612414151A(:,4)=A=16235111097641415D、多項式求多項式p(X)=x32X4的根答:P=1,0,-2,-4;roots(P)ans=2

22、.0000+0.0000i-1.0000+1.0000i-1.0000-1.0000i已知A=12350.9;51.756;3901;1234,求矩陣A的特征多項式;答:A=1.2350.9;51.756;3901;1234;B=poly(A)B=1.0000-6.9000-77.2600-86.1300604.5500P(s)=10000sM-69000sA3-7726OOsA2-861300s+6045500求矩陣多項式中未知數(shù)為20時的值;答:C=polyval(B,20)C=7.2778e+04把矩陣A作為未知數(shù)代入到多項式中;答:D=polyval(B,A)D=1.0e+03*0.3

23、801-0.4545-1.99510.4601-1.99510.2093-1.9951-2.8880-0.4545-4.89780.60450.43530.43530.0841-0.4545-1.1617二、上機練習實驗(1)利用help檢査roots指令的使用方法,然后求4xA4-3xA3+2xA2-x+1=0的所有根。答:helprootsroots-PolynomialrootsThisMATLABfunctionreturnsacolumnvectorwhoseelementsaretherootsofthepolynomialc.r=roots(c)P=4,-3,2,-1,1;roo

24、ts(P)ans=0.5917+0.4864i0.5917-0.4864i-0.2167+0.6158i-0.2167-0.6158i(2)令A是一個維度mxn的矩陣.解釋max(A)和min(max(A)分別是什么意思?答:A=rand(3,4)A=0.81470.91340.27850.96490.90580.63240.54690.15760.12700.09750.95750.9706max(A)ans=0.90580.91340.95750.9706min(max(A)ans=0.9058(3)令x是一個維度n的向量.解釋find(x08*max(x)是什么意思?答:find(x0.

25、8*max(x)的意思是從向量中找出大于最大值0.8倍的所有數(shù)據(jù)得位置。令x=2356和y=-l:2而z=x.Ay,解釋z的值是什么?答:x=2356;y=-1:2y=-1012z=x.Ayz=0.50001.00005.000036.0000試用解析解和數(shù)值解的方法求解微分方程x(t)=-2x(t)-3x(t)+exp(-5t)y(t)=2x(t)-3y(t)-4x(t)-4y(t)-sintx(0)=1,x(0)=2,y(0)=3,y(0)=4解析解:x,y=dsolve(D2x=(-2)*x-3*Dx+exp(-5*t),D2y=2*x-3*y-4*Dx-4*Dy-sint,x(0)=1

26、,Dx(0)=2,y(0)=3,Dy(0)=4)x=-(exp(-2*t)*(20*exp(t)*(3*exp(-4*t)/4-51/4)-20*exp(-3*t)+200)/60y=-(exp(-3*t)*(sint-(21*exp(-2*t)/2-sint*exp(3*t)+3*exp(t)*(20*exp(-3*t)/3-200/3)+6*exp(2*t)*(3*exp(-4*t)/4-51/4)-6*exp(2*t)*(sint/2+(exp(-4*t)*(12*t-8*sint*exp(5*t)+41)/16-465/16)+6*t*exp(2*t)*(3*exp(-4*t)/4-5

27、1/4)+171)/6計算y=sinx+sin2x+sin3x,在x=n/處得值。答:symsx;f=sin(x)+sin(2*x)+sin(3*x);subs(f,x,pi/6)ans=3A(1/2)/2+3/2Idx用符號方法求積分1+x4+x8答:symsx;f=1/(1+(xA4)+(xA8);int(f,x)ans=-(3A(1/2)*(atan(2*3A(1/2)*x)/(3*(2*xA2)/3-2/3)-atanh(2*3A(1/2)*x)/(3*(2*xA2)/3+2/3)/6x(esinx+1)一2(etanx1)lim(8)用符號方法求下列極限:xT0sin3x答:syms

28、x;f=(x*(power(exp(1),sin(x)+1)-2*(power(exp(1),tan(x)-1)/(power(sin(x),3);limit(f,x,O)ans=-Inf(9)用3次多項式方法插值計算1-100之間整數(shù)的平方根。N149162536496481100平方根12345678910答:n=(1:10).人2;f=sqrt(n);interpl(n,f,(l:100),cubic)ans=Columns1through71.00001.37291.7125Columns8through142.00002.24052.45512.64942.82923.00003.1

29、6363.31863.46613.60693.7422Columns15through213.87294.00004.12374.24354.35994.47304.5832Columns22through284.69074.79584.89885.00005.09935.19665.2921Columns29through355.38575.47775.56815.65705.74465.83095.9160Columns36through426.00006.08296.16476.24546.32496.40356.4810Columns43through496.55776.63346.7

30、0826.78236.85566.92817.0000Columns50through567.07127.14167.21137.28047.34877.41647.4835Columns57through637.55007.61597.68127.74597.81027.87397.9372Columns64through708.00008.06238.12428.18558.24648.30688.3668Columns71through778.42638.48548.54418.60248.66038.71788.7749Columns78through848.83178.88818.94429.00009.05559.11079.1655Columns85through919.22019.27449.32849.38219.43549.48849.5412Columns92through989.59359.64569.69739.74

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論