利用matlab編寫(xiě)S函數(shù)求解微分方程_第1頁(yè)
利用matlab編寫(xiě)S函數(shù)求解微分方程_第2頁(yè)
已閱讀5頁(yè),還剩3頁(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、實(shí)用文案標(biāo)準(zhǔn)文檔自動(dòng)化專業(yè)綜合設(shè)計(jì)報(bào)告設(shè)計(jì)題目:利用matlab編與S函數(shù)求解微分方程所在實(shí)驗(yàn)室:自動(dòng)化系統(tǒng)仿真實(shí)驗(yàn)室指導(dǎo)教師:郭衛(wèi)平學(xué)生姓名律迪迪班級(jí)文自 0921學(xué)號(hào) 200990519114成績(jī)?cè)u(píng)定:_實(shí)用文案標(biāo)準(zhǔn)文檔一、設(shè)計(jì)目的了解使用 simulink 的擴(kuò)展工具- S-函數(shù),s 函數(shù)可以利用 matlab 的豐富資源,而不僅僅局限于 simulink 提供的模塊,而用 c 或 C+等語(yǔ)言寫(xiě)的 s 函數(shù)還可以實(shí)現(xiàn)對(duì)硬件端口的操 作,還可以操作 windows API 等的,它的魅力在于完美結(jié)合了simulink 框圖簡(jiǎn)潔明快的特點(diǎn)和編程靈活方便的優(yōu)點(diǎn),提供了增強(qiáng)和擴(kuò)展 sin uli

2、 nk能力的強(qiáng)大機(jī)制,同時(shí)也是使用 RTW實(shí)現(xiàn)實(shí)時(shí)仿真的關(guān)鍵。、設(shè)計(jì)要求求解解微分方程y =y_2x/yy(o)=i要求利用 matlab 編寫(xiě) S 函數(shù)求解三、設(shè)計(jì)內(nèi)容(可加附頁(yè))【步驟 1】獲取狀態(tài)空間表達(dá)式。在 matlab 中輸入dsolve( Dy=y-2*x/y , y(0)=1;x)得到y(tǒng)=(2*x+1).A(1/2);【步驟 2】建立 s 函數(shù)的 m 文件。利用 21 用 S 函數(shù)模板文件。 以下是修改之后的模板文件 sfun tmpl.m 的內(nèi)容。function sys,xO,str,ts = sfun tmpl(t,x,u,flag)%SFUNTMPL General M

3、-file S-fu nctio n template% With M-file S-functions, you can defi ne you own ordinary differe ntial% equati ons (ODEs), discrete system equati ons, an d/or just about% any type of algorithm to be used within a Simulink block diagram.% The gen eral form of an M-File S-fu nctio n syntax is:% SYS,XO,S

4、TR,TS = SFUNC(T,X,U,FLAG,P1,.,P n)% What is retur ned by SFUNC at a give n point in time, T, depe nds on the% value of the FLAG, the curre nt state vector, X, and the curre nt% in put vector, U.% FLAG RESULTDESCRIPTION% _ _ _% 0 SIZES,XO,STR,TS In itializatio n, return system sizes in SYS,實(shí)用文案標(biāo)準(zhǔn)文檔%i

5、n itial state in X0, state orderi ng stri ngs%in STR, and sample times in TS.%1DXReturn continuous state derivatives in SYS.%2DSUpdate discrete states SYS = X(n+1)% 3YRetur n outputs in SYS.% 4TNEXTReturn next time hit for variable step sample%time in SYS.% 5Reserved for future (root findin g).% 9Te

6、rmi natio n, perform any clea nup SYS=.% The state vectors, X and X0 con sists of con ti nu ous states followed% by discrete states.% Opti onal parameters, P1,.,P n can be provided to the S-function and% used duri ng any FLAG operati on.% When SFUNC is called with FLAG = 0, the followi ng in formati

7、o n% should be retur ned:% SYS(1) = Number of contin uous states.% SYS(2) = Number of discrete states.% SYS(3) = Number of outputs.% SYS(4) = Number of in puts.%Any of the first four eleme nts in SYS can be specified%as -1 in dicat ing that they are dyn amically sized. The%actual le ngth for all oth

8、er flags will be equal to the%len gth of the in put, U.% SYS(5) = Reserved for root finding. Must be zero.% SYS(6) = Direct feedthrough flag(仁yes, 0=n o). The s-fu ncti on%has direct feedthrough if U is used duri ng the FLAG=3%call. Setting this to 0 is akin to making a promise that%U will not be us

9、ed duri ng FLAG=3. If you break the promise%the n un predictable results will occur.% SYS(7) = Number of sample times. This is the nu mber of rows in TS.% X0= In itial state con diti ons or if no states.% STR = State orderi ng stri ngs which is gen erally specified as .% TS = An m-by-2 matrix containing the sample time%(period, offset) in formati on. Where m = nu mber of sample%times. The orderi ng of the sample times must be:%實(shí)用文案標(biāo)準(zhǔn)文檔%TS = 00,: Continu ous sample time.%01,: Continu ous, but fixed in minor step%sample time.%PERIOD OF

溫馨提示

  • 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ù)網(wǎng)僅提供信息存儲(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)論