計(jì)算機(jī)仿真-北京交通大學(xué)電氣工程學(xué)院_第1頁(yè)
已閱讀1頁(yè),還剩82頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、在抗擊“非典”期間,學(xué)校課程安排受到很大的影響,因此對(duì)授課的方式和內(nèi)容作了相應(yīng)的修改:,1、取消第四章,將仿真實(shí)例的學(xué)習(xí)排入前三章,要求同學(xué)通過(guò)自己的上機(jī)實(shí)踐學(xué)習(xí)Matlab和Simulink的基本操作。2、原上機(jī)實(shí)踐部分的內(nèi)容安排為幾個(gè)范例的學(xué)習(xí)。同學(xué)們應(yīng)充分利用范例對(duì)所涉及的關(guān)鍵內(nèi)容進(jìn)行實(shí)踐。,計(jì) 算 機(jī) 仿 真 技 術(shù),童 亦 斌2003.4,系統(tǒng)的分析方法,系統(tǒng):客觀世界中相互作用的實(shí)體所構(gòu)成的具有特定功能的整體。為了定量

2、分析系統(tǒng),可將其本身的特點(diǎn)和內(nèi)部的相互關(guān)系抽象出來(lái),構(gòu)造出系統(tǒng)的模型。對(duì)系統(tǒng)的分析變成對(duì)系統(tǒng)模型的分析。系統(tǒng)模型:分物理模型和數(shù)學(xué)模型,由于計(jì)算機(jī)技術(shù)的發(fā)展,數(shù)學(xué)模型的應(yīng)用越來(lái)越廣泛。系統(tǒng)的數(shù)學(xué)模型:描述系統(tǒng)動(dòng)態(tài)特性的數(shù)學(xué)表達(dá)式。根據(jù)系統(tǒng)的性質(zhì)和數(shù)學(xué)分析工具可分為:連續(xù)系統(tǒng)、離散時(shí)間系統(tǒng)、離散事件系統(tǒng)、混合系統(tǒng)等。,系統(tǒng)的仿真分析方法,仿真技術(shù):用模擬的方法模擬實(shí)際系統(tǒng)的表現(xiàn)。仿真技術(shù)的基本方法:數(shù)學(xué)模型仿真、物理模型仿真、硬件

3、仿真、操作仿真、虛擬現(xiàn)實(shí)。系統(tǒng)仿真:根據(jù)系統(tǒng)數(shù)學(xué)模型研究系統(tǒng)性能。計(jì)算機(jī)仿真:利用計(jì)算機(jī)完成對(duì)系統(tǒng)的仿真。本課程特指利用計(jì)算機(jī)、根據(jù)系統(tǒng)的數(shù)學(xué)模型對(duì)電路系統(tǒng)進(jìn)行仿真。,計(jì)算機(jī)仿真技術(shù)講授內(nèi)容,計(jì)算機(jī)仿真技術(shù)概述Matlab和Simulink簡(jiǎn)介計(jì)算機(jī)仿真的建模計(jì)算機(jī)仿真實(shí)例計(jì)算機(jī)仿真上機(jī)實(shí)踐,本課程的學(xué)習(xí)方法、作業(yè)和考試,學(xué)習(xí)方法:特別強(qiáng)調(diào)直接在計(jì)算機(jī)進(jìn)行實(shí)踐,強(qiáng)調(diào)學(xué)習(xí)利用Matlab各種資源解決問(wèn)題;作業(yè):分別關(guān)于Mat

4、lab的基本使用、Simulink的建模、S函數(shù)和Simulink結(jié)果的調(diào)用;考試:建立一個(gè)交流異步電機(jī)變頻啟動(dòng)的計(jì)算機(jī)仿真模型,對(duì)交流異步電機(jī)的變頻啟動(dòng)過(guò)程進(jìn)行觀察;,交流電機(jī)變頻系統(tǒng)框圖,考試的基本要求和條件,基本要求-利用搭建的模型研究變頻啟動(dòng)過(guò)程中電機(jī)電流的變化情況;條件:電源電壓直流600V、電機(jī)為Simulink默認(rèn)的交流異步電機(jī)、電機(jī)空載、采用理想IGBT逆變器橋、開(kāi)關(guān)頻率固定為2500Hz、輸出頻率從5Hz變化到50

5、Hz、啟動(dòng)時(shí)間可調(diào);,第一章 計(jì)算機(jī)仿真技術(shù)概述,為什么要進(jìn)行計(jì)算機(jī)仿真?計(jì)算機(jī)仿真能完成什么任務(wù)?計(jì)算機(jī)仿真技術(shù)的關(guān)鍵仿真軟件的發(fā)展?fàn)顩r電子設(shè)計(jì)自動(dòng)化的主要應(yīng)用領(lǐng)域計(jì)算機(jī)仿真的基本步驟計(jì)算機(jī)仿真設(shè)計(jì)的原則,§1.1 為什么要進(jìn)行計(jì)算機(jī)仿真?,實(shí)際系統(tǒng)的理論分析往往非常復(fù)雜,傳統(tǒng)的分析方法幾乎不可能完成;很多時(shí)候幾乎不可能或很難進(jìn)行真實(shí)實(shí)驗(yàn)的分析和驗(yàn)證;實(shí)驗(yàn)的成本高、效率低、周期長(zhǎng);,通過(guò)計(jì)算機(jī)仿真我們能夠

6、:,提高設(shè)計(jì)效率、縮短設(shè)計(jì)周期;準(zhǔn)確、全面地模擬和分析系統(tǒng);提高產(chǎn)品和技術(shù)的設(shè)計(jì)質(zhì)量;降低設(shè)計(jì)成本;充分發(fā)揮設(shè)計(jì)人員的創(chuàng)造性;降低干擾因素的影響,集中注意于關(guān)鍵問(wèn)題;優(yōu)化系統(tǒng)和參數(shù)的設(shè)計(jì),§1.2 計(jì)算機(jī)仿真能完成什么任務(wù)?,動(dòng)態(tài)系統(tǒng)的仿真分析;參數(shù)的優(yōu)化;極限參數(shù)的設(shè)計(jì);環(huán)境參數(shù)對(duì)系統(tǒng)性能的影響;突發(fā)或偶發(fā)事件的模擬;電子設(shè)計(jì)自動(dòng)化(Electronic Design Automation),

7、7;1.3 計(jì)算機(jī)仿真技術(shù)的關(guān)鍵,數(shù)值計(jì)算算法;電路數(shù)學(xué)模型建立的模塊化;不同應(yīng)用軟件間的數(shù)據(jù)共享;仿真計(jì)算的效率和準(zhǔn)確性;混合系統(tǒng)的建模和仿真;仿真結(jié)果的可視化;,§1.4 仿真軟件的發(fā)展?fàn)顩r,現(xiàn)代仿真軟件的特點(diǎn):功能強(qiáng)大的數(shù)學(xué)軟件包作為計(jì)算引擎、交互式的編程方式、友好的圖形界面、豐富的模型資源和良好的程序接口等;,早期仿真語(yǔ)言和程序,早期數(shù)學(xué)軟件包,現(xiàn)代的仿真軟件,§1.5 電子設(shè)計(jì)自動(dòng)化的主要應(yīng)

8、用領(lǐng)域,EDA的主要應(yīng)用領(lǐng)域包括:-集成電路設(shè)計(jì)-模擬電路仿真-動(dòng)態(tài)系統(tǒng)的仿真EDA主要軟件及特點(diǎn):Protel、Pspice、Saber、Matlab,§1.6 計(jì)算機(jī)仿真的基本步驟,計(jì)算機(jī)仿真過(guò)程包括分析、建模、計(jì)算和驗(yàn)證;模型的調(diào)試和計(jì)算主要依靠仿真軟件的設(shè)計(jì)和使用;驗(yàn)證過(guò)程非常重要;人為的干預(yù)和控制對(duì)仿真的效果有很大的影響;,系統(tǒng)和任務(wù)分析,建立系統(tǒng)的仿真模型,模型的調(diào)試與計(jì)算,仿真結(jié)果的驗(yàn)證

9、,§1.7 計(jì)算機(jī)仿真設(shè)計(jì)的原則,“分級(jí)仿真”原則:對(duì)系統(tǒng)的分析應(yīng)根據(jù)任務(wù)的不同采用不同的仿真模型或算法,合理簡(jiǎn)化系統(tǒng),突出問(wèn)題的關(guān)鍵;“準(zhǔn)確度與速度合理兼顧”原則:在仿真的不同階段合理調(diào)整對(duì)準(zhǔn)確度和速度的要求,提高仿真效率;“可信驗(yàn)證”原則:所有仿真結(jié)果應(yīng)有可信的驗(yàn)證方法或依據(jù);,第二章 Matlab和Simulink簡(jiǎn)介,Matlab和Simulink簡(jiǎn)介MATLAB InstallationMATLAB De

10、sktopArrayScripts and FunctionsSimulink交互式仿真環(huán)境SolverS-Function,§2.0 Matlab和Simulink簡(jiǎn)介,Matlab是集數(shù)值計(jì)算、符號(hào)運(yùn)算和圖形處理功能于一身的超級(jí)科學(xué)計(jì)算語(yǔ)言;與其它計(jì)算語(yǔ)言相比,Matlab在功能、開(kāi)放性和易學(xué)性等方面獨(dú)占鰲頭;Matlab的核心是數(shù)值計(jì)算,Simulink是建立系統(tǒng)框圖和仿真的環(huán)境;,* Battery(s

11、)V0 43 0 DC 15V; V1 39 0 DC 15V; *DISCHARGEV_0 41 0 PULSE(-15 15 196ms 10us 10us 20ms 200ms); *OFFSETV_1 5 0 PULSE(5 -5.7 150ms 10us 10us 50ms 200ms); *PIBIASV_2 1 0 PULSE(10 -10 190ms 2us 2us 10ms 200ms); *

12、Misc.TRAN 10us 210ms 0s 10ms UIC,語(yǔ)句方式,框圖方式,§2.1 MATLAB Installation,The main Products of Matlab for modeling and simulating dynamical systems:-Matlab-Symbolic Math-Simulink-Control System,§2.2 MATL

13、AB Desktop,Command Window(指令窗)Command History(歷史指令窗)Launch Pad(交互界面分類(lèi)目錄窗)Help Browser(幫助瀏覽器)Current Directory Browser(當(dāng)前目錄瀏覽器)Workspace Browser(工作空間瀏覽器)Array Editor(內(nèi)存數(shù)組瀏覽器)Editor/Debugger(M文件編輯/調(diào)試器),Launch Pad,,C

14、urrent Directory Browser,Command Window,Matlab常用標(biāo)點(diǎn)的功能,§2.3 Array,Array(數(shù)組)的基本概念數(shù)組在Matlab仿真計(jì)算中的應(yīng)用Numeric Array(數(shù)值數(shù)組)數(shù)值元素的標(biāo)識(shí)Character Array(字符串?dāng)?shù)組)Cell Array(元胞數(shù)組)Structure Array(架構(gòu)數(shù)組),§2.3.1 Array(數(shù)組)的基本概

15、念,MATLAB works with only a single object-the array(數(shù)組)。數(shù)組:一組數(shù)組成的長(zhǎng)方陣列。Its typeIts dimensionsIts contentThe data associated with this arrayIf numeric,whether the variable is real or complexIf a structure,the n

16、umber of fields and field names,數(shù)組與矩陣的區(qū)別,矩陣:作為一種變換或映射算子的體現(xiàn),矩陣有著明確而嚴(yán)格的數(shù)學(xué)規(guī)則;數(shù)組:Matlab設(shè)置數(shù)組的目的主要是為了簡(jiǎn)化數(shù)據(jù)的管理和操作、使指令的形式更加自然、程序的運(yùn)行更加有效;Matlab中對(duì)數(shù)組的計(jì)算實(shí)際上是對(duì)數(shù)組中每個(gè)元素平等地施加同樣地操作;,§2.3.2 數(shù)組在Matlab仿真計(jì)算中的應(yīng)用,Matlab中數(shù)據(jù)的存放和處理均采用數(shù)組;M

17、atlab中的數(shù)組主要分為:Numeric Array,Character Array,Cell Array, Structure ArrayCharacter Array可用于仿真結(jié)果和過(guò)程的可視化;Structure Array可用于與Simulink交換信息,包括仿真參數(shù)的設(shè)定、結(jié)果的獲取和處理等;,§2.3.3 Numeric Array(數(shù)值數(shù)組),數(shù)值數(shù)組是Matlab中最基本地?cái)?shù)組形式;數(shù)值數(shù)組分實(shí)數(shù)

18、數(shù)組和復(fù)數(shù)數(shù)組;,>> A=[1 2 3 4,5 6 7 8]A = 1 2 3 4 5 6 7 8>> A=[1 2 3 4;5 6 7 8]A = 1 2 3 4 5 6 7 8>> A*4ans = 4 8 12 16

19、 20 24 28 32,§2.3.4 數(shù)組元素的標(biāo)識(shí),“全下標(biāo)”標(biāo)識(shí)“單下標(biāo)”標(biāo)識(shí),>> A(4)ans = 6>> A(1,4)ans = 4>> A(2,3)=0;>> AA = 1 2 3 4 5 6 0 8,A = 1 2 3 4

20、 5 6 7 8,單下標(biāo),全下標(biāo),冒號(hào)的使用,j:kis the same as [j,j+1,...,k]j:i:kis the same as [j,j+i,j+2i, ...,k]A(:,j)is the j-th column of AA(i,:)is the i-th row of A,§2.3.5 Character Array(字符串?dāng)?shù)組),字符串?dāng)?shù)組-基本元素是字

21、符串。字符串?dāng)?shù)組可用于計(jì)算過(guò)程和結(jié)果的可視化。字符串?dāng)?shù)組的直接創(chuàng)建。利用串操作函數(shù)創(chuàng)建串?dāng)?shù)組。,A = ‘The exmaple of the Character Arrays',>> A=['1234 ';'12345']A =1234 12345,>> A=char('1234','12345')A =1234 1234

22、5,轉(zhuǎn)換函數(shù)產(chǎn)生數(shù)碼字符串,Int2str(整數(shù)數(shù)組轉(zhuǎn)換為串?dāng)?shù)組);Num2str(非整數(shù)數(shù)組轉(zhuǎn)換為串?dāng)?shù)組);,A=rand(2,4)A =0.9501 0.6068 0.8913 0.4565 0.2311 0.4860 0.7621 0.0185B=num2str(A,2),C=int2str(A)B =0.95 0.61 0.89 0.46

23、 0.23 0.49 0.76 0.019C =1 1 1 0 0 0 1 0class(B),class(C)ans =charans =char,clear%清除內(nèi)存中地所有變a=2,w=3;%t=0:0.01:10;%取自變量采樣數(shù)組y=exp(-a*t).*sin(w*t);%計(jì)算函數(shù)值,產(chǎn)生函數(shù)數(shù)組[y_max,i_max]=

24、max(y);%找最大值的位置t_text=[‘t=’,num2str(t(i_max))];%生成最大值點(diǎn)的橫坐標(biāo)字符串y_text=[‘y=’,num2str(y_max)];%生成最大值點(diǎn)的眾坐標(biāo)字符串max_text=char('maximum',t_text,y_text);%生成最大值點(diǎn)的字符串tit=['y=exp(-',num2str(a),'t)*

25、sin(',num2str(w),'t)'];%plot(t,zeros(size(t)),‘k’);%畫(huà)縱坐標(biāo)為0的基準(zhǔn)線hold on%plot(t,y,‘b’);%繪制函數(shù)曲線plot(t(i_max),y_max,‘r.’,‘MarkerSize’,20);%標(biāo)注最大值點(diǎn)text(t(i_max)+0.3,y_max+0.05,max_text);%標(biāo)注最

26、大值點(diǎn)的字符串title(tit),xlabel(‘t’),ylabel(‘y’),hold off%標(biāo)注圖名、橫坐標(biāo)名、縱坐標(biāo)名,字符串?dāng)?shù)組用于計(jì)算結(jié)果的可視化實(shí)例,字符串?dāng)?shù)組用于計(jì)算結(jié)果的可視化實(shí)例,§2.3.6 Cell Array(元胞數(shù)組),The elements of a cell array are cells, containers that can hold other MATLAB arrays.

27、,§2.3.6.1 Creating Cell Arrays,Cell indexing(元胞外標(biāo)識(shí)):A(1,1) = {[1 4 3; 0 5 8; 7 2 9]};A(1,2) = {'Anne Smith'};A(2,1) = {3+7i};A(2,2) = {-pi:pi/10:pi};,A(1,1) = {[1 4 3; 0 5 8; 7 2 9]};A(1,2) = {'Ann

28、e Smith'};A(2,1) = {3+7i};A(2,2) = {-pi:pi/10:pi};A = [3x3 double] 'Anne Smith' [3.0000+ 7.0000i] [1x21 double],Content indexin(元胞內(nèi)標(biāo)識(shí)):A{1,1} = [1 4 3; 0 5 8; 7 2 9];A{1,2} = 'Anne Smith'

29、;A{2,1} = 3+7i;A{2,2} = -pi:pi/10:pi;,§2.3.6.2 Obtaining Data from Cell Arrays,調(diào)取元胞數(shù)據(jù)分:元胞的調(diào)取和元胞內(nèi)容的調(diào)??;元胞地標(biāo)識(shí)分:元胞外標(biāo)識(shí)和元胞內(nèi)標(biāo)識(shí);,A{1,1}ans =1 4 3 0 5 8 7 2 9A{1,1}(1,2)ans = 4,A

30、(1,1)={[1 2 3;4 5 6]};A(1,1)=[2x3 double]A{1,1}=1 2 3 4 5 6,§2.3.7 Structure Array(構(gòu)架數(shù)組),The elements of a Structure Array are Structures.Structures are MATLAB arrays with "dat

31、a containers" called fields. The fields of a structure can contain any kind of data. Structure Array的基本組分是架構(gòu)( Structure) ,在Structure以下劃分了域(Field),域可用于存放任何形式的數(shù)據(jù)。,§2.3.7.1 Structure Array的基本結(jié)構(gòu),patient.name = &

32、#39;John Doe';patient.billing = 127.00;patient.test = [79 75 73; 180 178 177.5; 220 210 205];,A Structure Array,A Structure,§2.3.7.2 Building Structure Arrays,方法一:直接聲明patient(2).name = 'Ann Lane';pa

33、tient(2).billing = 28.50;patient(2).test = [68 70 68; 118 118 119; 172 170 169];,方法二:利用struct指令patient(2)=struct('name','Ann Lane','billing',28.50,'test',[68 70 68; 118 118 119; 172 170

34、169])patient = 1x2 struct array with fields:namebillingtest,§2.3.7.3 Accessing Data in Structure Arrays,架構(gòu)數(shù)組的存?。杭軜?gòu)->域->內(nèi)容,mypatients = patient(1:2)1x2 struct array with fields: name billing

35、test,mypatients(1)ans = name: 'John Doe' billing: 127 test: [3x3 double],str = patient(2).namestr =Ann Lane,patient(2).testans = 68 70 68 118 118 119 172 170 169,

36、§2.4 Scripts and Functions,Scripts(腳本文件), which do not accept input arguments or return output arguments. They operate on data in the workspace.Functions(函數(shù)文件), which can accept input arguments and return output a

37、rguments. Internal variables are local to the function.,§2.4.1 Scripts,When you invoke a script, Matlab simply executes the commands found in the file. Scripts can operate on existing data in the workspace, or the

38、y can create new data on which to operate. Although scripts do not return output arguments, any variables that they create remain in the workspace, to be used in subsequent computations.Scripts在使用Simulink時(shí)的主要作用:作為調(diào)用Simu

39、link模型的外部環(huán)境。,§2.4.2 Flow Control,Scripts中可以使用各種流程控制,用于控制Simulink的調(diào)用或參數(shù)的設(shè)置。主要的流程控制包括:-if statements-switch statements-for loops-while loops,§2.4.2.1 if statements,判斷結(jié)構(gòu),if rem(n,2) ~= 0 M = odd_magi

40、c(n)elseif rem(n,4) ~= 0 M = single_even_magic(n)else M = double_even_magic(n)end,§2.4.2.2 switch statements,選擇結(jié)構(gòu),switch (rem(n,4)==0) + (rem(n,2)==0) case 0 M = odd_magic(n) case 1 M

41、 = single_even_magic(n) case 2 M = double_even_magic(n) otherwise error('This is impossible') end,§2.4.2.3 for loops,For循環(huán),for n = 3:32 r(n) = rank(magic(n));end,§2.4.2.4 wh

42、ile loops,While(條件)循環(huán),while b-a > eps*b x = (a+b)/2; fx = x^3-2*x-5; if sign(fx) == sign(fa) a = x; fa = fx; else b = x; fb = fx; endend,§2.4.3 Functions(函數(shù)),Create a Function,Call a

43、Function,function area=circle(r,s)%CIRCUIT this is keyword of the function% next is comment linesclf; %clear current figure windowsita=0:pi/100:2*pi;y=r*exp(i*sita);plot(y,s);area=pi*r^2;,c

44、ircle(2,'r')ans = 12.5664 x=circle(2,'b')x= 12.5664,Function最典型的應(yīng)用S-Function,§2.5 Simulink交互式仿真環(huán)境,Simulink,the most widely used software package in academia and industry for modeling and si

45、mulating dynamical systems.Interactive,you can change parameters and see what happens immediately.Simulink provides a graphical user interface (GUI).Simulink is practical,it is being used by thousands of engineers aro

46、und the world.,Simulink的基本操作Modeling Dynamic SystemsSimulating Dynamic SystemsModeling and Simulating Discrete Systems,§2.5.1 Modeling Dynamic Systems,Blocks(模塊)States(狀態(tài))System Functions(仿真運(yùn)行功能)Continuous an

47、d Discrete Blocks(連續(xù)和離散系統(tǒng))Sample Time(采樣時(shí)間),§2.5.1.1 Blocks(模塊),Blocks-Each block represents an elementary dynamic system that produces an output.Simulink本身具有比較豐富的Block資源,應(yīng)首先予以考慮。,為方便設(shè)計(jì),最好遵照下述命名規(guī)則:u:輸入x:(內(nèi)部)狀態(tài)

48、y:輸出,§2.5.1.2 States(內(nèi)部狀態(tài)),A block that has a state must store previous values of the state to compute its current state.Examples of the blocks that have STATES:Integrator,Unit DelayThe Simulink Gain block is

49、an example of a stateless block.,§2.5.1.3 System Functions(仿真運(yùn)行功能),所謂System Functions是指仿真計(jì)算的三個(gè)循環(huán)步驟:1、An output function(輸出):Relates the system's outputs to its inputs, states, and time,y=f(t,x,u)2、An update f

50、unction(離散狀態(tài)刷新): Relates the future values of the system‘s discrete states to the current time,inputs, and states,xdk+1= f(t,x,u)3、A derivative function(連續(xù)狀態(tài)刷新):Relates the derivatives of the continuous states to time a

51、nd the present values of the states and inputs,xc’= f(t,x,u),§2.5.1.4 Continuous and Discrete Blocks,Continuous blocks respond continuously to continuously changing input.Discrete blocks respond to changes in inpu

52、t only at the block's sample time. Discrete blocks hold their output constant between successive sample time hits.Some blocks can be either continuous or discrete,depending on whether they are driven by continuous o

53、r discrete blocks.,§2.5.2 Simulating Dynamic Systems,Model Initialization PhaseModel Execution PhaseProcessing at Each Time Step,§2.5.2.1 Model Initialization Phase,During the initialization phase, Simulink

54、:1、Evaluates the model's block parameter expressions to determine their values.2、Flattens the model hierarchy by replacing virtual subsystems with the blocks that they contain.3、Sorts the blocks into the order in

55、which they need to be executed during the execution phase.4、Determines signal attributes.5、Determines the sample times.6、Allocates and initializes memory used to store the current values of each block's states and

56、 outputs.,§2.5.2.2 Model Execution Phase,Simulink successively computes the states and outputs of the system at intervals from the simulation start time to the finish time, using information provided by the model.

57、The successive time points at which the states and outputs are computed are called time steps. The length of time between steps is called the step size.Simulink決定計(jì)算步長(zhǎng)依據(jù):用戶的設(shè)定、離散模塊或系統(tǒng)的采樣時(shí)間、數(shù)值計(jì)算的誤差。,§2.5.2.3 Proces

58、sing at Each Time Step,At each time step, Simulink1、Updates the outputs of the models' blocks in sorted order.2、Updates the states of the model's blocks in sorted order.3、Optionally checks for discontinuiti

59、es in the continuous states of blocks.4、Computes the time for the next time step.,§2.5.3 Modeling and Simulating Discrete Systems,Discrete BlocksSample TimePurely Discrete SystemsMultirate SystemsDetermining

60、 Step Size for Discrete SystemsSample Time PropagationInvariant ConstantsMixed Continuous and Discrete Systems,§2.5.3.1 Discrete Blocks,Each of the discrete blocks hasA built-in sampler at its inputA zero-or

61、der hold at its output,§2.5.3.2 Sample Time,The Sample time parameter sets the sample time at which a discrete block's states are updated.Specify an offset time (or skew) by specifying a two-element vector in

62、this field.Cannot change the sample time of a block while a simulation is running.,§2.5.3.3 Purely Discrete Systems & Multirate Systems,Purely Discrete Systems:系統(tǒng)中所有模塊都按單一的采樣率進(jìn)行工作.Multirate Systems:系統(tǒng)中的模塊采用不同

63、的采樣率進(jìn)行工作.,§2.5.3.4 Determining Step Size for Discrete Systems,The fundamental sample time of a discrete system is the greatest integral divisor of the system's actual sample times.You can direct Simulink to us

64、e either a fixed-step or a variable-step discrete solver to solve a discrete system.,§2.5.3.5 Mixed Continuous and Discrete Systems,Mixed continuous and discrete systems are composed of both sampled and continuous

65、blocks.For most mixed continuous and discrete systems, the Runge-Kutta variable step methods, ode23 and ode45, are superior to the other methods in terms of efficiency and accuracy. Due to discontinuities associated wit

66、h the sample and hold of the discrete blocks, the ode15s and ode113 methods are not recommended for mixed continuous and discrete systems.,§2.6 Solver(解算控制),The Solver pane allows you to:-Set the simulation start

67、 and stop times-Choose the solver and specify its parameters-Select output options,§2.7 Data Exchange Within Simulink and Workspace,Workspace I/O Pane-You can direct simulation output to workspace variables and

68、 get input and initial states from the workspace.,From Workspace Block & To Workspace Block,§2.8 S-Function,What Is an S-Function?-An S-function is a computer language description of a Simulink block.When to

69、 Use an S-Function?-Adding new general purpose blocks to Simulink-Adding blocks that represent hardware device drivers-Incorporating existing C code into a simulation-Describing a system as a mathematical set of

70、equations-Using graphical animations (see the inverted pendulum demo, penddemo),Mathematics of Simulink Blocks,S-Function:實(shí)際上是利用Matlab的編程語(yǔ)言直接設(shè)計(jì)模塊的數(shù)學(xué)模型S-Function的運(yùn)行主要由三個(gè)環(huán)節(jié)組成:output,derivative,update,The stages of a sim

71、ulation.,S-Function的運(yùn)行實(shí)際上是一個(gè)循環(huán)調(diào)用的過(guò)程,Implementing S-Functions,An M-file S-function: [sys,x0,str,ts]=f(t,x,u,flag,p1,p2,...)f-S-function's namet-the current timex-the state vector of the S-function blocku-the b

溫馨提示

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

評(píng)論

0/150

提交評(píng)論