已阅读5页,还剩78页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
.,1,在抗击“非典”期间,学校课程安排受到很大的影响,因此对授课的方式和内容作了相应的修改:,1、取消第四章,将仿真实例的学习排入前三章,要求同学通过自己的上机实践学习Matlab和Simulink的基本操作。2、原上机实践部分的内容安排为几个范例的学习。同学们应充分利用范例对所涉及的关键内容进行实践。,.,2,计算机仿真技术,童亦斌2003.4,.,3,系统的分析方法,系统:客观世界中相互作用的实体所构成的具有特定功能的整体。为了定量分析系统,可将其本身的特点和内部的相互关系抽象出来,构造出系统的模型。对系统的分析变成对系统模型的分析。系统模型:分物理模型和数学模型,由于计算机技术的发展,数学模型的应用越来越广泛。系统的数学模型:描述系统动态特性的数学表达式。根据系统的性质和数学分析工具可分为:连续系统、离散时间系统、离散事件系统、混合系统等。,.,4,系统的仿真分析方法,仿真技术:用模拟的方法模拟实际系统的表现。仿真技术的基本方法:数学模型仿真、物理模型仿真、硬件仿真、操作仿真、虚拟现实。系统仿真:根据系统数学模型研究系统性能。计算机仿真:利用计算机完成对系统的仿真。本课程特指利用计算机、根据系统的数学模型对电路系统进行仿真。,.,5,计算机仿真技术讲授内容,计算机仿真技术概述Matlab和Simulink简介计算机仿真的建模计算机仿真实例计算机仿真上机实践,.,6,本课程的学习方法、作业和考试,学习方法:特别强调直接在计算机进行实践,强调学习利用Matlab各种资源解决问题;作业:分别关于Matlab的基本使用、Simulink的建模、S函数和Simulink结果的调用;考试:建立一个交流异步电机变频启动的计算机仿真模型,对交流异步电机的变频启动过程进行观察;,交流电机变频系统框图,.,7,考试的基本要求和条件,基本要求利用搭建的模型研究变频启动过程中电机电流的变化情况;条件:电源电压直流600V、电机为Simulink默认的交流异步电机、电机空载、采用理想IGBT逆变器桥、开关频率固定为2500Hz、输出频率从5Hz变化到50Hz、启动时间可调;,.,8,第一章计算机仿真技术概述,为什么要进行计算机仿真?计算机仿真能完成什么任务?计算机仿真技术的关键仿真软件的发展状况电子设计自动化的主要应用领域计算机仿真的基本步骤计算机仿真设计的原则,.,9,1.1为什么要进行计算机仿真?,实际系统的理论分析往往非常复杂,传统的分析方法几乎不可能完成;很多时候几乎不可能或很难进行真实实验的分析和验证;实验的成本高、效率低、周期长;,.,10,通过计算机仿真我们能够:,提高设计效率、缩短设计周期;准确、全面地模拟和分析系统;提高产品和技术的设计质量;降低设计成本;充分发挥设计人员的创造性;降低干扰因素的影响,集中注意于关键问题;优化系统和参数的设计,.,11,1.2计算机仿真能完成什么任务?,动态系统的仿真分析;参数的优化;极限参数的设计;环境参数对系统性能的影响;突发或偶发事件的模拟;电子设计自动化(ElectronicDesignAutomation),.,12,1.3计算机仿真技术的关键,数值计算算法;电路数学模型建立的模块化;不同应用软件间的数据共享;仿真计算的效率和准确性;混合系统的建模和仿真;仿真结果的可视化;,.,13,1.4仿真软件的发展状况,现代仿真软件的特点:功能强大的数学软件包作为计算引擎、交互式的编程方式、友好的图形界面、丰富的模型资源和良好的程序接口等;,早期仿真语言和程序,早期数学软件包,现代的仿真软件,.,14,1.5电子设计自动化的主要应用领域,EDA的主要应用领域包括:集成电路设计模拟电路仿真动态系统的仿真EDA主要软件及特点:Protel、Pspice、Saber、Matlab,.,15,1.6计算机仿真的基本步骤,计算机仿真过程包括分析、建模、计算和验证;模型的调试和计算主要依靠仿真软件的设计和使用;验证过程非常重要;人为的干预和控制对仿真的效果有很大的影响;,系统和任务分析,建立系统的仿真模型,模型的调试与计算,仿真结果的验证,.,16,1.7计算机仿真设计的原则,“分级仿真”原则:对系统的分析应根据任务的不同采用不同的仿真模型或算法,合理简化系统,突出问题的关键;“准确度与速度合理兼顾”原则:在仿真的不同阶段合理调整对准确度和速度的要求,提高仿真效率;“可信验证”原则:所有仿真结果应有可信的验证方法或依据;,.,17,第二章Matlab和Simulink简介,Matlab和Simulink简介MATLABInstallationMATLABDesktopArrayScriptsandFunctionsSimulink交互式仿真环境SolverS-Function,.,18,2.0Matlab和Simulink简介,Matlab是集数值计算、符号运算和图形处理功能于一身的超级科学计算语言;与其它计算语言相比,Matlab在功能、开放性和易学性等方面独占鳌头;Matlab的核心是数值计算,Simulink是建立系统框图和仿真的环境;,*Battery(s)V0430DC15V;V1390DC15V;*DISCHARGEV_0410PULSE(-1515196ms10us10us20ms200ms);*OFFSETV_150PULSE(5-5.7150ms10us10us50ms200ms);*PIBIASV_210PULSE(10-10190ms2us2us10ms200ms);*Misc.TRAN10us210ms0s10msUIC,语句方式,框图方式,.,19,2.1MATLABInstallation,ThemainProductsofMatlabformodelingandsimulatingdynamicalsystems:MatlabSymbolicMathSimulinkControlSystem,.,20,2.2MATLABDesktop,CommandWindow(指令窗)CommandHistory(历史指令窗)LaunchPad(交互界面分类目录窗)HelpBrowser(帮助浏览器)CurrentDirectoryBrowser(当前目录浏览器)WorkspaceBrowser(工作空间浏览器)ArrayEditor(内存数组浏览器)Editor/Debugger(M文件编辑/调试器),.,21,LaunchPad,CurrentDirectoryBrowser,CommandWindow,.,22,Matlab常用标点的功能,.,23,2.3Array,Array(数组)的基本概念数组在Matlab仿真计算中的应用NumericArray(数值数组)数值元素的标识CharacterArray(字符串数组)CellArray(元胞数组)StructureArray(架构数组),.,24,2.3.1Array(数组)的基本概念,MATLABworkswithonlyasingleobjectthearray(数组)。数组:一组数组成的长方阵列。ItstypeItsdimensionsItscontentThedataassociatedwiththisarrayIfnumeric,whetherthevariableisrealorcomplexIfastructure,thenumberoffieldsandfieldnames,.,25,数组与矩阵的区别,矩阵:作为一种变换或映射算子的体现,矩阵有着明确而严格的数学规则;数组:Matlab设置数组的目的主要是为了简化数据的管理和操作、使指令的形式更加自然、程序的运行更加有效;Matlab中对数组的计算实际上是对数组中每个元素平等地施加同样地操作;,.,26,2.3.2数组在Matlab仿真计算中的应用,Matlab中数据的存放和处理均采用数组;Matlab中的数组主要分为:NumericArray,CharacterArray,CellArray,StructureArrayCharacterArray可用于仿真结果和过程的可视化;StructureArray可用于与Simulink交换信息,包括仿真参数的设定、结果的获取和处理等;,.,27,2.3.3NumericArray(数值数组),数值数组是Matlab中最基本地数组形式;数值数组分实数数组和复数数组;,A=1234,5678A=12345678A=1234;5678A=12345678A*4ans=48121620242832,.,28,2.3.4数组元素的标识,“全下标”标识“单下标”标识,A(4)ans=6A(1,4)ans=4A(2,3)=0;AA=12345608,A=12345678,单下标,全下标,.,29,冒号的使用,j:kisthesameasj,j+1,.,kj:i:kisthesameasj,j+i,j+2i,.,kA(:,j)isthej-thcolumnofAA(i,:)isthei-throwofA,.,30,2.3.5CharacterArray(字符串数组),字符串数组基本元素是字符串。字符串数组可用于计算过程和结果的可视化。字符串数组的直接创建。利用串操作函数创建串数组。,A=TheexmapleoftheCharacterArrays,A=1234;12345A=123412345,A=char(1234,12345)A=123412345,.,31,转换函数产生数码字符串,Int2str(整数数组转换为串数组);Num2str(非整数数组转换为串数组);,A=rand(2,4)A=0.95010.60680.89130.45650.23110.48600.76210.0185B=num2str(A,2),C=int2str(A)B=0.950.610.890.460.230.490.760.019C=11100010class(B),class(C)ans=charans=char,.,32,clear%清除内存中地所有变a=2,w=3;%t=0:0.01:10;%取自变量采样数组y=exp(-a*t).*sin(w*t);%计算函数值,产生函数数组y_max,i_max=max(y);%找最大值的位置t_text=t=,num2str(t(i_max);%生成最大值点的横坐标字符串y_text=y=,num2str(y_max);%生成最大值点的众坐标字符串max_text=char(maximum,t_text,y_text);%生成最大值点的字符串tit=y=exp(-,num2str(a),t)*sin(,num2str(w),t);%plot(t,zeros(size(t),k);%画纵坐标为0的基准线holdon%plot(t,y,b);%绘制函数曲线plot(t(i_max),y_max,r.,MarkerSize,20);%标注最大值点text(t(i_max)+0.3,y_max+0.05,max_text);%标注最大值点的字符串title(tit),xlabel(t),ylabel(y),holdoff%标注图名、横坐标名、纵坐标名,字符串数组用于计算结果的可视化实例,.,33,字符串数组用于计算结果的可视化实例,.,34,2.3.6CellArray(元胞数组),Theelementsofacellarrayarecells,containersthatcanholdotherMATLABarrays.,.,35,CreatingCellArrays,Cellindexing(元胞外标识):A(1,1)=143;058;729;A(1,2)=AnneSmith;A(2,1)=3+7i;A(2,2)=-pi:pi/10:pi;,A(1,1)=143;058;729;A(1,2)=AnneSmith;A(2,1)=3+7i;A(2,2)=-pi:pi/10:pi;A=3x3doubleAnneSmith3.0000+7.0000i1x21double,Contentindexin(元胞内标识):A1,1=143;058;729;A1,2=AnneSmith;A2,1=3+7i;A2,2=-pi:pi/10:pi;,.,36,ObtainingDatafromCellArrays,调取元胞数据分:元胞的调取和元胞内容的调取;元胞地标识分:元胞外标识和元胞内标识;,A1,1ans=143058729A1,1(1,2)ans=4,A(1,1)=123;456;A(1,1)=2x3doubleA1,1=123456,.,37,2.3.7StructureArray(构架数组),TheelementsofaStructureArrayareStructures.StructuresareMATLABarrayswithdatacontainerscalledfields.Thefieldsofastructurecancontainanykindofdata.StructureArray的基本组分是架构(Structure),在Structure以下划分了域(Field),域可用于存放任何形式的数据。,.,38,StructureArray的基本结构,=JohnDoe;patient.billing=127.00;patient.test=797573;180178177.5;220210205;,AStructureArray,AStructure,.,39,BuildingStructureArrays,方法一:直接声明patient(2).name=AnnLane;patient(2).billing=28.50;patient(2).test=687068;118118119;172170169;,方法二:利用struct指令patient(2)=struct(name,AnnLane,billing,28.50,test,687068;118118119;172170169)patient=1x2structarraywithfields:namebillingtest,.,40,AccessingDatainStructureArrays,架构数组的存取:架构域内容,mypatients=patient(1:2)1x2structarraywithfields:namebillingtest,mypatients(1)ans=name:JohnDoebilling:127test:3x3double,str=patient(2).namestr=AnnLane,patient(2).testans=687068118118119172170169,.,41,2.4ScriptsandFunctions,Scripts(脚本文件),whichdonotacceptinputargumentsorreturnoutputarguments.Theyoperateondataintheworkspace.Functions(函数文件),whichcanacceptinputargumentsandreturnoutputarguments.Internalvariablesarelocaltothefunction.,.,42,2.4.1Scripts,Whenyouinvokeascript,Matlabsimplyexecutesthecommandsfoundinthefile.Scriptscanoperateonexistingdataintheworkspace,ortheycancreatenewdataonwhichtooperate.Althoughscriptsdonotreturnoutputarguments,anyvariablesthattheycreateremainintheworkspace,tobeusedinsubsequentcomputations.Scripts在使用Simulink时的主要作用:作为调用Simulink模型的外部环境。,.,43,2.4.2FlowControl,Scripts中可以使用各种流程控制,用于控制Simulink的调用或参数的设置。主要的流程控制包括:ifstatementsswitchstatementsforloopswhileloops,.,44,ifstatements,判断结构,ifrem(n,2)=0M=odd_magic(n)elseifrem(n,4)=0M=single_even_magic(n)elseM=double_even_magic(n)end,.,45,switchstatements,选择结构,switch(rem(n,4)=0)+(rem(n,2)=0)case0M=odd_magic(n)case1M=single_even_magic(n)case2M=double_even_magic(n)otherwiseerror(Thisisimpossible)end,.,46,forloops,For循环,forn=3:32r(n)=rank(magic(n);end,.,47,whileloops,While(条件)循环,whileb-aeps*bx=(a+b)/2;fx=x3-2*x-5;ifsign(fx)=sign(fa)a=x;fa=fx;elseb=x;fb=fx;endend,.,48,2.4.3Functions(函数),CreateaFunction,CallaFunction,functionarea=circle(r,s)%CIRCUITthisiskeywordofthefunction%nextiscommentlinesclf;%clearcurrentfigurewindowsita=0:pi/100:2*pi;y=r*exp(i*sita);plot(y,s);area=pi*r2;,circle(2,r)ans=12.5664x=circle(2,b)x=12.5664,Function最典型的应用S-Function,.,49,2.5Simulink交互式仿真环境,Simulink,themostwidelyusedsoftwarepackageinacademiaandindustryformodelingandsimulatingdynamicalsystems.Interactive,youcanchangeparametersandseewhathappensimmediately.Simulinkprovidesagraphicaluserinterface(GUI).Simulinkispractical,itisbeingusedbythousandsofengineersaroundtheworld.,.,50,Simulink的基本操作ModelingDynamicSystemsSimulatingDynamicSystemsModelingandSimulatingDiscreteSystems,.,51,2.5.1ModelingDynamicSystems,Blocks(模块)States(状态)SystemFunctions(仿真运行功能)ContinuousandDiscreteBlocks(连续和离散系统)SampleTime(采样时间),.,52,Blocks(模块),BlocksEachblockrepresentsanelementarydynamicsystemthatproducesanoutput.Simulink本身具有比较丰富的Block资源,应首先予以考虑。,为方便设计,最好遵照下述命名规则:u:输入x:(内部)状态y:输出,.,53,States(内部状态),Ablockthathasastatemuststorepreviousvaluesofthestatetocomputeitscurrentstate.ExamplesoftheblocksthathaveSTATES:Integrator,UnitDelayTheSimulinkGainblockisanexampleofastatelessblock.,.,54,SystemFunctions(仿真运行功能),所谓SystemFunctions是指仿真计算的三个循环步骤:1、Anoutputfunction(输出):Relatesthesystemsoutputstoitsinputs,states,andtime,y=f(t,x,u)2、Anupdatefunction(离散状态刷新):Relatesthefuturevaluesofthesystemsdiscretestatestothecurrenttime,inputs,andstates,xdk+1=f(t,x,u)3、Aderivativefunction(连续状态刷新):Relatesthederivativesofthecontinuousstatestotimeandthepresentvaluesofthestatesandinputs,xc=f(t,x,u),.,55,ContinuousandDiscreteBlocks,Continuousblocksrespondcontinuouslytocontinuouslychanginginput.Discreteblocksrespondtochangesininputonlyattheblockssampletime.Discreteblocksholdtheiroutputconstantbetweensuccessivesampletimehits.Someblockscanbeeithercontinuousordiscrete,dependingonwhethertheyaredrivenbycontinuousordiscreteblocks.,.,56,2.5.2SimulatingDynamicSystems,ModelInitializationPhaseModelExecutionPhaseProcessingatEachTimeStep,.,57,ModelInitializationPhase,Duringtheinitializationphase,Simulink:1、Evaluatesthemodelsblockparameterexpressionstodeterminetheirvalues.2、Flattensthemodelhierarchybyreplacingvirtualsubsystemswiththeblocksthattheycontain.3、Sortstheblocksintotheorderinwhichtheyneedtobeexecutedduringtheexecutionphase.4、Determinessignalattributes.5、Determinesthesampletimes.6、Allocatesandinitializesmemoryusedtostorethecurrentvaluesofeachblocksstatesandoutputs.,.,58,ModelExecutionPhase,Simulinksuccessivelycomputesthestatesandoutputsofthesystematintervalsfromthesimulationstarttimetothefinishtime,usinginformationprovidedbythemodel.Thesuccessivetimepointsatwhichthestatesandoutputsarecomputedarecalledtimesteps.Thelengthoftimebetweenstepsiscalledthestepsize.Simulink决定计算步长依据:用户的设定、离散模块或系统的采样时间、数值计算的误差。,.,59,ProcessingatEachTimeStep,Ateachtimestep,Simulink1、Updatestheoutputsofthemodelsblocksinsortedorder.2、Updatesthestatesofthemodelsblocksinsortedorder.3、Optionallychecksfordiscontinuitiesinthecontinuousstatesofblocks.4、Computesthetimeforthenexttimestep.,.,60,2.5.3ModelingandSimulatingDiscreteSystems,DiscreteBlocksSampleTimePurelyDiscreteSystemsMultirateSystemsDeterminingStepSizeforDiscreteSystemsSampleTimePropagationInvariantConstantsMixedContinuousandDiscreteSystems,.,61,DiscreteBlocks,EachofthediscreteblockshasAbuilt-insampleratitsinputAzero-orderholdatitsoutput,.,62,SampleTime,TheSampletimeparametersetsthesampletimeatwhichadiscreteblocksstatesareupdated.Specifyanoffsettime(orskew)byspecifyingatwo-elementvectorinthisfield.Cannotchangethesampletimeofablockwhileasimulationisrunning.,.,63,PurelyDiscreteSystems&MultirateSystems,PurelyDiscreteSystems:系统中所有模块都按单一的采样率进行工作.MultirateSystems:系统中的模块采用不同的采样率进行工作.,.,64,DeterminingStepSizeforDiscreteSystems,Thefundamentalsampletimeofadiscretesystemisthegreatestintegraldivisorofthesystemsactualsampletimes.YoucandirectSimulinktouseeitherafixed-steporavariable-stepdiscretesolvertosolveadiscretesystem.,.,65,MixedContinuousandDiscreteSystems,Mixedcontinuousanddiscretesystemsarecomposedofbothsampledandcontinuousblocks.Formostmixedcontinuousanddiscretesystems,theRunge-Kuttavariablestepmethods,ode23andode45,aresuperiortotheothermethodsintermsofefficiencyandaccuracy.Duetodiscontinuitiesassociatedwiththesampleandholdofthediscreteblocks,theode15sandode113methodsarenotrecommendedformixedcontinuousanddiscretesystems.,.,66,2.6Solver(解算控制),TheSolverpaneallowsyouto:SetthesimulationstartandstoptimesChoosethesolverandspecifyitsparametersSelectoutputoptions,.,67,2.7DataExchangeWithinSimulinkandWorkspace,WorkspaceI/OPane-Youcandirectsimulationoutputtoworkspacevariablesandgetinputandinitialstatesfromtheworkspace.,.,68,FromWorkspaceBlock&ToWorkspaceBlock,.,69,2.8S-Function,WhatIsanS-Function?-AnS-functionisacomputerlanguagedescriptionofaSimulinkblock.WhentoUseanS-Function?-AddingnewgeneralpurposeblockstoSimulink-Addingblocksthatrepr
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 临床试验风险获益再评估的标准化工具
- 毕业答辩小组评语
- 临床路径联合CBL模拟教学在消化内科教学中的实践
- 1.0皖西学院本科毕业设计(论文)撰写格式规范(试行)
- 临床试验脱落风险预警模型构建与应用
- 临床路径联合PBL模拟教学在呼吸科教学中的实践
- 临床试验结果传播与公众信任建设
- 第三单元作文议论要言之有据-2025-2025学年初中语文九年级上册课件
- ASO诊断、疗效标准2025(终稿)-
- 一体化成本管理信息化平台与费用透明化
- 北师大版八年级上学期数学 第4章 一次函数 单元测试(附答案)
- 安检员服务礼仪培训大纲
- DB4201∕T 493-2016 绿色食品 设施叶菜栽培技术规程
- 小区地下管道安装施工方案
- 专项纪检监察培训课件
- 2025年及未来5年中国建筑安装行业市场前景预测及投资方向研究报告
- 幼儿园晨间活动目标及实施细则
- 新员工仓管员述职报告
- 2025年房地产买卖居间合同协议
- 铁路护路安全知识教育
- 外研版初三英语下册教案
评论
0/150
提交评论