第七章Simulink基礎_第1頁
第七章Simulink基礎_第2頁
第七章Simulink基礎_第3頁
第七章Simulink基礎_第4頁
第七章Simulink基礎_第5頁
已閱讀5頁,還剩7頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

第七章 Simulink 基礎Chapter 7: Introduction to Simulink一 Simulink 初步(Primer of Simulink)MATLAB Simulink是一個動態(tài)仿真系統(tǒng),用于對動態(tài)系統(tǒng)進行仿真和分析,預先模擬實際系統(tǒng)的特性和響應,根據(jù)設計和使用要求,對系統(tǒng)進行修改和優(yōu)化。Simulink提供了圖形化用戶界面,只須點擊鼠標就可以輕易的完成模型的創(chuàng)建、調(diào)試和仿真工作,用戶不須專門掌握一種程序設計語言。Simulink可將系統(tǒng)分為從高級到低級的幾個層次,每層又可以細分為幾個部分,每層系統(tǒng)構(gòu)建完成后,將各層連接起來構(gòu)成一個完整系統(tǒng)。模型創(chuàng)建完成后,可以啟動系統(tǒng)的仿真功能分析系統(tǒng)的動態(tài)特性,其內(nèi)置的分析工具包括各種仿真算法、系統(tǒng)線性化、尋求平衡點等。仿真結(jié)果可以以圖形方式在示波器窗口顯示,也可將輸出結(jié)果以變量形式保存起來,并輸入到MATLAB中以完成進一步的分析。Simulink可以仿真線性和非線性系統(tǒng),并能創(chuàng)建連續(xù)時間、離散時間或二者混合的系統(tǒng)。支持多采樣頻率系統(tǒng)。Simulink Version 6.0 (R14) 05-May-2004 Model analysis and construction functions.Simulation sim - Simulate a Simulink model. sldebug - Debug a Simulink model. simset - Define options to SIM Options structure. simget - Get SIM Options structure Linearization and trimming. linmod - Extract linear model from continuous-time system. linmod2 - Extract linear model, advanced method. dlinmod - Extract linear model from discrete-time system. trim - Find steady-state operating point. Model Construction. close_system - Close open model or block. new_system - Create new empty model window. open_system - Open existing model or block. load_system - Load existing model without making model visible. save_system - Save an open model. add_block - Add new block. add_line - Add new line. delete_block - Remove block. delete_line - Remove line. find_system - Search a model. hilite_system - Hilite objects within a model. replace_block - Replace existing blocks with a new block. set_param - Set parameter values for model or block. get_param - Get simulation parameter values from model. add_param - Add a user-defined string parameter to a model. delete_param - Delete a user-defined parameter from a model. bdclose - Close a Simulink window. bdroot - Root level model name. gcb - Get the name of the current block. gcbh - Get the handle of the current block. gcs - Get the name of the current system. getfullname - get the full path name of a block slupdate - Update older 1.x models to 3.x. addterms - Add terminators to unconnected ports. boolean - Convert numeric array to boolean. slhelp - Simulink users guide or block help. Masking. hasmask - Check for mask. hasmaskdlg - Check for mask dialog. hasmaskicon - Check for mask icon. iconedit - Design block icons using ginput function. maskpopups - Return and change masked blocks popup menu items. movemask - Restructure masked built-in blocks as masked subsystems. Library. libinfo - Get library information for a system. Diagnostics. sllastdiagnostic - Last diagnostic array. sllasterror - Last error array. sllastwarning - Last warning array. sldiagnostics - Get block count and compile stats for a model. Hardcopy and printing. frameedit - Edit print frames for annotated model printouts. print - Print graph or Simulink system; or save graph to M-file. printopt - Printer defaults. orient - Set paper orientation. simulink is both a directory and a function.Copyright 1990-2004 The MathWorks, Inc. Simulink的三大步驟(procedure of Simulink):模型創(chuàng)建與定義、( Model creating and definition)模型的分析、(Model analyzing)模型的修正。(Model modifying)Simulink的運行:(Running of Simulink)1、運行Simulink:命令窗口下點擊Simulink圖標(或鍵入Simulink命令)Simulink Library Browser(瀏覽器)simulink樹狀列表形式的模塊庫(包含simulink模塊庫中的各種模塊及其它Toolbox和 Blockset中的模塊)2、選擇建模模塊:展開樹狀列表,用鼠標點擊所需類別的模塊項, 所選模塊類的具體模塊庫就在右側(cè)的列表框中顯示出來,提供建模使用。也可以在在輸入欄中鍵入模塊名并點擊Find按鈕進行查詢。3、打開模型創(chuàng)建窗口:(open the window of mode creating)。在工具欄中選擇“建立新模型”的圖標,彈出名為Untitled的空白窗口,選擇Open窗口可以打開存于硬盤中已建的模型,完成模型的運行或修改。二 Simulink 的基本模塊(basic module)simulink瀏覽器窗口左側(cè)的simulink項上單擊鼠標右鍵,彈出菜單“Open the SimulinkLabrary”選項,將打開simulink模塊庫窗口。1信號源模塊:source,模塊及功能見(表 81)2輸出模塊:Sinks, 模塊及功能見(表 82)3. 連續(xù)系統(tǒng)模塊: Continuous, 模塊及功能見(表 83)4. 離散系統(tǒng)模塊:Discrete, 模塊及功能見(表 84)5. 數(shù)學運算模塊:Math, 模塊及功能見(表 85)6函數(shù)和表模塊: Function & Tables, 模塊及功能見(表 86)7. 非線性系統(tǒng)模塊:Nonlinear, 模塊及功能見(表 87)8. 信號與系統(tǒng)模塊:Signal & Systems, 模塊及功能見(表 88)三. Simulink 建模(Simulinc module creating)1 模塊的創(chuàng)建與操作(Creating and operation of Simulink)(1) 創(chuàng)建模塊:(module creating)()在瀏覽器列表中點擊需要的模塊,按住鼠標左鍵并拖曳至模型窗口即可。()雙擊模塊可在彈出的對話框中修改相應的模塊參數(shù)()在模塊下方名稱處雙擊可改變模塊名稱。(2)模塊操作(module operation)(a)模塊的選擇(module selection)(b)移動模塊 (module moving)(c)模塊的縮放(modulee scaling)(d) 復制模塊:(module copy)四種方法: 在選定模塊處,按下鼠標右鍵并拖動至適當位置; 選定模塊,在工具欄中(或Edit菜單中)選中Copy與Paste按鈕; 在選定的模塊處點擊鼠標右鍵,在彈出的菜單中選擇Copy與Paste選項; 按住”Ctrl”鍵,按下鼠標左鍵,將選定的模塊拖至適當?shù)奈恢?。(e)模塊的旋轉(zhuǎn)與翻轉(zhuǎn):(Rotating and turnover of module)旋轉(zhuǎn):(rotate)將鼠標指向要翻轉(zhuǎn)的模塊并按下鼠標右鍵,選擇彈出菜單中的Format欄中的Rotate項,模塊順時針旋轉(zhuǎn)o。翻轉(zhuǎn):將鼠標指向要翻轉(zhuǎn)的模塊并按下鼠標右鍵,選擇彈出菜單中的Format欄中的Flip Block項,模塊順時針旋轉(zhuǎn)180o。(f) 模塊的連接 (h)連接分支線 (i)改變連線的形狀 (j)連線的標識:在連線的上或下方(或窗口內(nèi)任何位置)雙擊鼠標左鍵,可出現(xiàn)一個文本框用于輸入說明文字。(3)簡單模型(Simple mode) 信號發(fā)生器發(fā)生幅值為,頻率為0.2HZ的正弦波信號,信號分別按倍和倍送入兩個示波器。2 模型的修飾(Mode modifying) 1. 模塊加陰影:Format菜單中的Show drop shadow菜單項用于給模塊加陰影。2. 調(diào)整顏色:Format菜單中的Foreground color菜單項用于調(diào)整模塊的前景顏色。Background color菜單項用于選擇模塊的背景顏色。Screen color菜單項用于調(diào)整屏幕顏色。3. 變換模塊名的顯示位置:Format 菜單中的Flip name可將模塊名換到對稱的位置,Hide name可將模塊名隱藏起來。4. 模塊修飾的一個簡單示例三 仿真計算與分析方法(simulink calculation and the method of analyzing)1連續(xù)系統(tǒng)建模(Module creating of continuous system)(1)用積分模塊創(chuàng)建微分方程求解的模型(creating the solve mode of differential equation with integral modules): 有二階微分方程x+0.2x+0.4x=0.2u(t), u(t)是單位階躍函數(shù),演示如何用積分器直接創(chuàng)建求解該微分方程的模型。(a) 改寫微分方程為(reforming differential equation): x=0.2u(t)-0.2x-0.4x(b) 利用Simulink庫中的標準模塊建模(Creating mode with modules in the library of Simulink) :基本思路是x經(jīng)積分后得 x,再積分得 x,再將 x和 x經(jīng)代數(shù)運算得到 x。結(jié)果送入示波器,也可同時存儲在工作空間變量simy中。(2)用傳遞函數(shù)模塊求解(Solving by transfer function module):以二階微分方程x+0.2x+0.4x=0.2u(t)為例, 初始狀態(tài)為0,u(t)是單位階躍函數(shù)。對方程兩邊進行Laplace變換,得到: s2X(s)+0.2sX(s)+0.4X(s)=0.2U(s)整理后得傳遞函數(shù):(Transfer function) G(s)=X(s)/U(s)=0.2/(s2+0.2s+0.4)利用上式采用傳遞函數(shù)模塊可建立求解微分方程的模型。2. Simulink 結(jié)果的分析(Analyzing of the results): 執(zhí)行simulink后檢查輸出結(jié)果并做進一步的分析與判斷。(1) 輸出信號的觀察(output signal observation)(a) 將信號輸出到顯示模塊(Export signal to display module)* Scope(示波器):將信號顯示在示波器的獨立窗口中,通過雙擊模塊即可打開示波器模塊。* XY Graph 顯示器模塊:在MATLAB圖形窗口繪制二維圖形, * Display模塊:將結(jié)果以數(shù)字形式顯示出來,在模塊中直接滾動顯示。標量、矢量和矩陣形式得結(jié)果輸出窗口結(jié)構(gòu)略有不同。(b)將仿真結(jié)果存儲到工作空間,再用繪圖命令在命令窗口繪制圖形,(save the result of simulink to workspace and plotting figure on window by using plot command) 有三種方法可供選擇:* 通過示波器模塊向工作空間存儲數(shù)據(jù);* 通過選擇Sinks函數(shù)庫中的To workspace模塊,將數(shù)據(jù)保存到工作空間的simout變量中,同時還可以產(chǎn)生一個存放時間數(shù)據(jù)的變量(缺省tout);*通過Simulation菜單選擇Simulation Paremeter菜單項中的WorkspaceI/O頁,根據(jù)各個參數(shù)的選擇來確定存儲的數(shù)據(jù)內(nèi)容的類型。(c). 將仿真結(jié)果通過輸出端口返回到MATLAB命令窗口,再利用繪圖命令繪出輸出圖形 (return the result of simulink from export to MATLAB window and then drawing the plot on window by using plot command) :在Sinks函數(shù)庫中有一個名為Out1的模塊,將數(shù)據(jù)輸入到這個模塊,該模塊就會將數(shù)據(jù)輸出到 MATLAB 命令窗口,并用名為 yout的變量保存,同時還將時間數(shù)據(jù)用 tout變量保存。 存儲在工作空間的結(jié)果可以進行進一步的分析。2使用一般的分析工具(the using of General analysis tool) (a). 線性化:將狀態(tài)空間所描述的線性系統(tǒng)輸入輸出關(guān)系由下式表示:x=Ax+Buy=Cx+Du其中:x 代表狀態(tài)矢量y代表輸出矢量u代表輸入矢量A,B,C,D為系統(tǒng)線性化的狀態(tài)空間矩陣 如創(chuàng)建用于線性化的系統(tǒng)模型名為lmod,并保存為”lmod.mdl”.在命令窗口輸入命令 A B C D=linmod(lmod)就可以獲得系統(tǒng)的常微分方程 lmod的狀態(tài)空間線性模型,返回系統(tǒng)線性化的狀態(tài)空間矩陣。A B C D=linmod(lmod)(A,B,C,D=LINMOD(SYS) obtains the state-space linear model of the system of ordinary differential equations described in the block diagram SYS when the state variables and inputs are set to the defaults specified in the block diagram.)(b)由狀態(tài)方程轉(zhuǎn)成LTI對象(transfer state equations to LTI object):一旦數(shù)據(jù)形成了狀態(tài)空間形式或者轉(zhuǎn)變成了LTI對象,就可以使用Control System Toolbox函數(shù)進行進一步的分析。利用ss函數(shù)可將上面線性化的系統(tǒng)轉(zhuǎn)成LTI對象,命令格式為: sys=ss(A,B,C,D)(c) 繪制波德圖:(Bode plot drawing) 用bode 函數(shù)可繪制波德圖,(相位、幅值與頻率的關(guān)系圖)bode(A,B,C,D) 或 bode(sys) BODE(SYS) draws the Bode plot of the LTI model SYS (created with either TF, ZPK, SS, or FRD). The frequency range and number of points are chosen automatically.(d)線性時間響應(Linear time response):給一個階躍信號(step signal):step(A,B,C,D) 或 step(sys) 線性化階響應或給一個脈沖信號(impulse):impulse(A,B,C,D) 或 impulse(sys)線性化脈沖響應(e)求系統(tǒng)平衡點(find the balance point of

溫馨提示

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

評論

0/150

提交評論