Simulink入门共21页
- 格式:ppt
- 大小:190.50 KB
- 文档页数:28
3 Creating a Simulink Model•“Overview of a Simple Model”on page3-2•“Creating the Simple Model”on page3-3•“Connecting Blocks in the Simple Model”on page3-9•“Simulating the Simple Model”on page3-143Creating a Simulink®ModelOverview of a Simple ModelYou can use Simulink software to model dynamic systems and simulate thebehavior of the models.The basic techniques you use to create a simple modelare the same techniques you will use for more complex models.To create this simple model,you need four blocks:•Sine Wave—Generates an input signal for the model.•Integrator—Processes the input signal.•Mux—Multiplexes the input signal and processed signal into a singlesignal.•Scope—Visualizes the signals in the model.After connecting the blocks,they model a system that integrates a sine wavesignal and displays the result along with the original signal.You can build this simple model yourself,starting with“Creating a NewModel”on page3-3.3-2Creating the Simple ModelCreating the Simple ModelIn this section...“Creating a New Model”on page3-3“Adding Blocks to a Model”on page3-4“Moving Blocks in the Model”on page3-8Creating a New ModelBefore creating a model,you need to start Simulink,and then open an emptymodel window.1If Simulink is not running,in the MATLAB Command Window,entersimulinkThe Simulink Library Browser opens.2From the Simulink Library Browser menu,select File>New>Model.A Simulink editor window opens with an empty model in the right pane.3-33Creating a Simulink®Model3Select File>Save as.The Save As dialog box opens.4In the File name box,enter a name for your model,and then click Save.For example,enter simple_model.The software saves your model with the filename simple_model.mdl.Adding Blocks to a ModelTo create a model,you begin by copying blocks from the Simulink LibraryBrowser to the Simulink editor window.For a description of the blocks in thisexample,see“Overview of a Simple Model”on page3-2.1In the Simulink Library Browser,select the Sources library.The Simulink Library Browser displays blocks from the Sources library inthe right pane.3-4Creating the Simple Model3-53Creating a Simulink®Model2Select the Sine Wave block,and then drag it to the editor window.A copy of the Sine Wave block appears in your model.3Add the following blocks to your model in the same way you added theSign Wave block.Library BlockSinks ScopeContinuous IntegratorSignal Routing MuxYour model now has the blocks you need for the simple model.3-6Creating the Simple Model3-73Creating a Simulink®ModelMoving Blocks in the ModelBefore you connect the blocks in your model,you should arrange themlogically to make the signal connections as straightforward as possible.Tomove a block in a model,you can either•Click and drag the block•Select the block,and then press the arrow keys on the keyboard1Move the Scope block after the Mux block output.2Move the Sine Wave and Integrator blocks before the Mux block Inputs.Your model should look similar to the following figure.Your next task is to connect the blocks together with signal lines.See“Connecting Blocks in the Simple Model”on page3-9.3-8Connecting Blocks in the Simple ModelConnecting Blocks in the Simple ModelIn this section...“Block Connections in a Model”on page3-9“Drawing Lines Between Blocks”on page3-9“Drawing a Branch Line”on page3-12Block Connections in a ModelAfter you add blocks to your model,you need to connect them.The connectinglines represent the signals within a model.Most blocks have angle brackets on one or both sides.These angle bracketsrepresent input and output ports:•The>symbol pointing into a block is an input port.•The>symbol pointing out of a block is an output port.Input port Output portDrawing Lines Between BlocksConnect the blocks by drawing lines between output ports and input ports.For how to add blocks to the model in this example,see“Adding Blocks toa Model”on page3-4.1Position your mouse pointer over the output port on the right side of theSine Wave block.3-93Creating a Simulink®Model2Drag a line from the output port to the top input port of the Mux block.While holding the mouse button down,the connecting line is shown as alight colored arrow.3Release the mouse button over the output port.Simulink connects the blocks with an arrow indicating the direction ofsignal flow.4Drag a line from the output port of the Integrator block to the bottom inputport on the Mux block.The Integrator block connects to the Mux block with a signal line.3-10Connecting Blocks in the Simple Model5Select the Mux block,hold down the Shift key,and then select the Scopeblock.A line is drawn between the blocks to connect them.Note The Shift+click shortcut is useful when you are connecting widelyseparated blocks,or when working with complex models.Your model should now look similar to the following figure.3-113Creating a Simulink®ModelDrawing a Branch LineThe simple model is almost complete,but one connection is missing.To finishthe model,you need to connect the Sine Wave block to the Integrator block.This final connection is somewhat different from the other three connections,which all connect output ports to input ports.Because the output port of theSine Wave block already has a connection,you must connect this existing lineto the input port of the Integrator block.The new line,called a branch line,carries the same signal that passes from the Sine Wave block to the Mux block.1Position the mouse pointer on the line between the Sine Wave and theMux block.2Hold down the Ctrl key,and then drag a line to the input port of theIntegrator block input port.This step adds a connection to the existing line and draws a line betweenthe connection and the input port of the Integrator block.3-12Connecting Blocks in the Simple Model3From the File menu,click Save.Your model is now complete.It should look similar to the following figure.After your model is complete,you can simulate the model.See“Simulatingthe Simple Model”on page3-14.3-133Creating a Simulink®ModelSimulating the Simple ModelIn this section...“Setting Simulation Options”on page3-14“Running a Simulation and Observing Results”on page3-15Setting Simulation OptionsBefore you simulate a model,you have to set simulation options.You specifyoptions,such as the stop time and solver,using the Model ConfigurationParameters dialog box.For how to build the model in this example,see“Creating the Simple Model”on page3-3.1In the Simulink editor window,select Simulation>ModelConfiguration Parameters.The Configuration Parameters dialog boxopens to the Solver pane.2In the Stop time field,enter20,and in the Max step size field,enter0.2.3Click OK.The software updates the parameter values with your changes and closesthe Configuration Parameters dialog box.For more information about Simulink configuration parameters,see“Configuration Parameters Dialog Box”.3-14Simulating the Simple Model Running a Simulation and Observing ResultsAfter entering your configuration parameter changes,you are ready tosimulate the simple model and visualize the simulation results.1In the Simulink editor window and from the menu,selectSimulation>Start.The simulation runs,and then stops when it reaches the stop time specifiedin the Model Configuration Parameters dialog box.Tip Alternatively,you can control a simulation by clicking the Startsimulation button and Stop simulation button on the editorwindow toolbar.2Double-click the Scope block.The Scope window opens and displays the simulation results.The plotshows a sine wave signal with the resulting cosine wave signal from theIntegrator block.3-153Creating a Simulink®Model3From the toolbar,click the Parameters button,and then the Graphicstab.The Scope Parameters dialog opens with figure editing commands.4Make changes to the appearance of the figure.For example,select whitefor the Figure and Axes background color,and change the signal line colorsto blue and green.Click the Apply button to see your changes.3-16Simulating the Simple Model5Select File>Close.The Simulink editor window closes with changes to your model and the configuration parameters.3-173Creating a Simulink®Model 3-184 Modeling a Dynamic Control System•“Understanding a Demo Model”on page4-2•“Simulating the Demo Model”on page4-11•“Moving Data Between MATLAB and the Demo Model”on page4-194Modeling a Dynamic Control SystemUnderstanding a Demo ModelIn this section...“Overview of the Demo Model”on page4-2“Opening the Demo Model”on page4-3“Anatomy of the Demo Model”on page4-4“Subsystems in the Demo Model”on page4-5“Subsystems and Masks”on page4-9“Creating a Subsystem”on page4-9“Creating a Subsystem Mask”on page4-10Overview of the Demo ModelThis demo model illustrates how you can use Simulink software to modela dynamic control system.The model defines a heating system and thethermodynamics of a house.It included the outdoor environment,the thermalcharacteristics of a house,and the house heating system.Use this model to explore common Simulink modeling tasks,such as•Grouping multiple blocks into a single subsystem block to simplify a blockdiagram.See“Subsystems in the Demo Model”on page4-5•Customizing the appearance of blocks using the masking feature.See“Creating a Subsystem Mask”on page4-10•Simulating a model and observing the results using a Scope block.See“Running the Simulation”on page4-11•Changing the input parameters of the model to investigate how the systemresponds.See“Changing the Thermostat Setting”on page4-12.•Importing data from the MATLAB workspace into a model beforesimulation.See“Importing Data from the MATLAB Workspace”on page4-19.•Exporting simulation data from the model back to the MATLAB workspace.See“Exporting Simulation Data to the MATLAB Workspace”on page4-23. 4-2Understanding a Demo Model Opening the Demo ModelThe demo model for this example is called sldemo_househeat.It models the heating system and thermodynamics of a house.1Start MATLAB,and then In the MATLAB Command Window,enter sldemo_househeatThe Simulink editor opens with the demo model.4Modeling a Dynamic Control SystemAnatomy of the Demo ModelThe demo model defines the dynamics of the outdoor environment,thethermal characteristics of the house,and the house heating system.It allowsyou to simulate how the thermostat setting and outdoor environment affectthe indoor temperature and cumulative heating costs.The demo model includes many of the same blocks you used to create thesimple model in Chapter3,“Creating a Simulink Model”.These include:•A Scope block(labeled PlotResults)on the far right,displays thesimulation results.•A Mux block at the bottom right,combines the indoor and outdoortemperature signals for the Scope.•A Sine Wave block(labeled Daily Temp Variation)at the bottom left,provides one of three data sources for the model.In the demo model,the thermostat is set to70degrees Fahrenheit.Thesystem models fluctuations in outdoor temperature by applying a sine wavewith amplitude of15degrees to a base temperature of50degrees.The three data inputs(sources)are provided by two Constant blocks(labeledSet Point and Avg Outdoor Temp),and the Sine Wave block(labeled DailyTemp Variation).The Scope block labeled PlotResults is the one output(sink).Understanding a Demo Model Subsystems in the Demo ModelThe sldemo_househeat demo model uses subsystems to simplify theappearance of the block diagram,create reusable components,and customizethe appearance of blocks.A subsystem is a hierarchical grouping of blocks encapsulated by a single Subsystem block.The demo model uses the following subsystems:Thermostat,Heater,House, Fahrenheit to Celsius,and Celsius to Fahrenheit1In the MATLAB Command Window,entersldemo_househeatThe demo model opens in the Simulink editor window.4Modeling a Dynamic Control System2Subsystems can be complex and contain many blocks that might otherwiseclutter a diagram.For example,double-click the House subsystem block toopen it.Contents of House subsystemThe subsystem receives heat flow and external temperature as inputs,which it uses to compute the current room temperature.You could leaveeach of these blocks in the main model window,but combining them as asubsystem helps simplify the block diagram.Understanding a Demo Model3A subsystems can also be simple and contain only a few blocks.Forexample,double-click the Thermostat subsystem block to open it.Contents of Thermostat subsystemThis subsystem models the operation of a thermostat,determining whenthe heating system is on or off.It contains only one Relay block,butlogically represents the thermostat in the block diagram..4Modeling a Dynamic Control SystemUnderstanding a Demo Model Subsystems and MasksSubsystems allows you to group related blocks into one block.They are also reusable,enabling you to implement an algorithm once and use it multiple times.For example,the model contains two instances of identical subsystems named Fahrenheit to Celsius.These subsystems convert the inside and outside temperatures from degrees Fahrenheit to degrees CelsiusYou can customize the appearance of a subsystem by using a process knownas masking.Masking a subsystem allows you to specify a unique icon anddialog box for the Subsystem block.For example,the House and Thermostat subsystems display custom icons that depict physical objects,while the conversion subsystems display custom dialog boxes when you double-clickthem.1Double-click the Fahrenheit to Celsius block.The custom dialog box for the F2C block opens.2To view the underlying blocks in the conversion subsystem,right-click thesubsystem block,point to Mask,and then select Look Under Mask.The editor displays the blocks behind the mask.Creating a SubsystemTo create a subsystem:1In the demo model window,select the set point and Fahrenheit to Celsiusblocks.4Modeling a Dynamic Control System2From the menu,select Diagram>Subsystem&Modeling Reference>Create Subsystem from Selection.The blocks are combined into one subsystem block.For more information about working with subsystems,see“CreatingSubsystems”in the Simulink User’s Guide.Creating a Subsystem MaskTo mask a subsystem:1In the demo model window,right-click the new subsystem block,and thenselect Mask>Add/Edit Mask.The Mask Editor dialog box opens.2From the Command list,select disp(show text in center of block).The dialog box displays the syntax for this command below the list.3In the Icon Drawing commands field,enter disp('SelectTemperature').4Click OK.The software masks the subsystem block with the text you entered.For more information about masking subsystems,see“Working with BlockMasks”in the Simulink User’s Guide.Simulating the Demo ModelSimulating the Demo ModelIn this section...“Running the Simulation”on page4-11“Changing the Thermostat Setting”on page4-12“Changing the Average outdoor Temperature”on page4-14“Changing the Daily Temperature Variation”on page4-16Running the SimulationSimulating the model allows you to observe how the thermostat setting andoutdoor environment affect the indoor temperature and the cumulativeheating cost.1In the demo model window,double-click the Scope block namedPlotResults.The software opens a Scope window that contains two axes with the labelsHeatCost and Temperatures.2From the menu,select Simulation>Start.The software simulates the model.As the simulation runs,the cumulativeheating cost appears on the HeatCost graph at the top of the Scope window.The indoor and outdoor temperatures appear on the Temperatures graphas yellow(top)and magenta(bottom)signals,respectively.4Modeling a Dynamic Control SystemChanging the Thermostat SettingOne of the most powerful benefits of modeling a system with Simulink isthe ability to interactively define the system inputs and observe changes inthe behavior of your model.This allows you to quickly evaluate your modeland validate the simulation results.Change the thermostat setting to68degrees Fahrenheit and observe howthe model responds.1In the Simulink editor window,double-click the Set Point block.TheSource Block Parameters dialog box opens.2In the Constant value field,enter68.Simulating the Demo Model3Click OK.The software applies your changes.4To rerun the simulation,select Simulation>Start.The software simulates the model.In the Scope window,notice that a lower thermostat setting reduces the cumulative heating cost.4Modeling a Dynamic Control SystemChanging the Average outdoor TemperatureChange the average outdoor temperature to45degrees Fahrenheit andobserve how the model responds.1In the Simulink editor window,double-click the Avg Outdoor Temp block.The Source Block Parameters dialog box opens.2In the Constant value field,enter45.Simulating the Demo Model3Click OK.The software applies your changes and closes the dialog box.4To rerun the simulation,select Simulation>Start.The software simulates the model dynamics.In the Scope window,noticethat a colder outdoor temperature increases the cumulative heating cost.4Modeling a Dynamic Control SystemChanging the Daily Temperature VariationDecrease the temperature variation to see how the model responds.1In the Simulink editor window,double-click the Daily Temp Variationblock.The Source Block Parameters dialog box opens.2In the Amplitude field,enter5.3Click OK.The software applies your changes and closes the dialog box.4To rerun the simulation,select Simulation>Start.The software simulates the model.In the Scope window,notice that amore stable outdoor temperature alters the frequency with which theheater operates.Simulating the Demo Model4Modeling a Dynamic Control SystemMoving Data Between MATLAB and the Demo ModelMoving Data Between MATLAB and the Demo ModelIn this section...“Importing Data from the MATLAB Workspace”on page4-19“Exporting Simulation Data to the MATLAB Workspace”on page4-23Importing Data from the MATLAB WorkspaceSimulink also allows you to import data from the MATLAB workspace to themodel input ports.This allows you to import actual physical data into yourmodel.For information about other data import capabilities,see“Importingand Exporting Simulation Data”in the Simulink User’s Guide.Note In this example,you will create a vector of temperature data inMATLAB,and use that data as an input to the Simulink model.To import data from the MATLAB workspace:1In the MATLAB Command Window,create time and temperature data byentering the following commands:x=(0:0.01:4*pi)';y=32+(5*sin(x));z=linspace(0,48,1257)';2In the Simulink editor window,select the Avg Outdoor Temp block,andthen press the Delete key to delete it.3Delete the following items from the model in the same way:•Daily Temp Variation block•Two input signal lines to the Sum block•Sum block4Modeling a Dynamic Control SystemThe model should now look similar to the following figure.Notice that theoutput signal from the Sum block changes to a red,dotted line,indicatingthat it is not connected to a block.4In the demo model window,select View>Library Browser.The Simulink Library Browser window opens.5In the Simulink Library Browser,select the Sources library.6From the Sources library right pane,select the In1block,and then drag itto the model window.Moving Data Between MATLAB and the Demo ModelAn In1block appears in the model window.7Connect the dotted line(originally connected to the Sum block)to the In1 block.8In the Simulink editor window,select Simulation>Configuration Parameters.The Configuration Parameters dialog box opens.9In the menu on the left side of the dialog,select Data Import/Export.The Data Import/Export pane opens.4Modeling a Dynamic Control System10Select the Input check box.11In the Input field,enter[z,y].12Click OK.The software applies your changes and closes the dialog box.13To rerun the simulation,select Simulation>Start.The software simulates the model.In the Scope window,notice that themodel ran using the imported data,showing colder temperatures andhigher heat use.Exporting Simulation Data to the MATLAB Workspace Once you have completed a model,you may want to export your simulation results to MATLAB workspace for further data analysis or visualization.For information about additional data export capabilities,see“Exporting Simulation Data”.To export the HeatCost data from the model to the MATLAB workspace:1In the Simulink Library Browser window,select the Sinks library.2From the Sinks library,select the Out1block,and then drag it to the top right of the demo model window.An Out1block appears in the model window.3Draw a branch line from the HeatCost signal line to the Out1block.For more information,see“Drawing a Branch Line”on page3-12.4Select Simulation>Configuration Parameters.The Configuration Parameters dialog box opens.5From the menu on the left side of the dialog box,select DataImport/Export.The Data Import/Export pane opens.6Select the Time and Output check boxes.7Click OK.The software applies your changes and closes the dialog box.8To rerun the simulation,select Simulation>Start.The software simulates the model and saves the time and HeatCost data to the MATLAB workspace.Notice that the tout and yout variables nowappear in the MATLAB workspace.。
simulink手册Simulink 是一种广泛应用于系统建模和仿真的图形化编程环境。
它是MATLAB 软件的一个重要组成部分,提供了一种直观且易于使用的方法,使工程师能够有效地设计和分析复杂系统。
Simulink 可以支持从简单的控制系统到复杂的多域物理系统的建模和仿真。
一. 简介在本部分中,我们将深入了解 Simulink,并介绍其基本概念和特性:- Simulink 的工作原理和基本组件- 如何创建模型和添加模块- 如何配置和连接模块- 模型参数设置和修改- 仿真和观察结果二. 模型建立与设计这一部分将探讨如何使用 Simulink 建立系统模型,并设计系统的基本组件:- 系统分析和建模的基本工具和方法- 多域建模的技巧和策略- 控制系统的设计和优化- 信号处理和滤波器设计- 物理系统的建模和仿真三. 信号和数据处理在这一部分中,我们将重点讨论信号处理和数据处理的相关主题,包括:- 数字信号处理基础- 时域和频域分析- 滤波器设计和实现- 信号采集和处理- 时序数据分析和处理四. 模型验证和测试本部分将探讨如何使用 Simulink 进行模型验证和测试的方法和技巧,包括:- 模型验证的基本原则和方法- 静态和动态测试的工具和技术- 模型覆盖度分析和测试案例设计- 测试结果的分析和评估- 仿真和实际测试的比较总结:通过本文,我们对 Simulink 的基本概念和功能有了深入的了解。
Simulink 提供了一个强大而直观的环境,用于系统建模和仿真。
我们了解了如何使用 Simulink 创建和配置模型,以及如何使用不同的模块进行系统设计和分析。
我们还探讨了信号和数据处理的相关主题,并了解了如何使用 Simulink 进行模型验证和测试。
Simulink 在工程领域具有广泛的应用前景,并为系统设计和开发工程师提供了强大的工具和方法。
观点和理解:从我个人的观点来看,Simulink 是一个非常有用的工具,可以帮助工程师更有效地设计和分析复杂系统。
要构建模型,可以使用Simulink® Editor 和Library Browser。
启动 MATLAB 软件启动Simulink 之前,请先启动MATLAB®。
请参阅启动和关闭 (MATLAB)。
配置 MATLAB 以启动 Simulink您在MATLAB 会话中打开第一个模型时需要的时间比打开后续模型长,因为默认情况下,MATLAB 会在打开第一个模型时启动Simulink。
这种即时启动Simulink 的方法可以缩短MATLAB 启动时间,避免不必要的系统内存占用。
要快速打开第一个模型,您可以配置MATLAB,在它启动时同时启动Simulink。
要启动Simulink 而不打开模型或Library Browser,请使用start_simulink。
根据MATLAB 的启动方式,恰当使用此命令:•在MATLAB startup.m 文件中•在操作系统命令行中,使用 matlab 命令和 -r 开关例如,要在运行Microsoft® Windows®操作系统的计算机上启动MATLAB 时启动Simulink,请创建具有以下目标的桌面快捷方式:matlabroot\bin\win64\matlab.exe -r start_simulink在Macintosh 和 Linux®计算机上,可在启动MATLAB 时使用以下命令启动Simulink 软件:matlab -r start_simulink打开 Simulink Editor要打开Simulink Editor,您可以:•创建一个模型。
在MATLAB 的Home选项卡上,点击Simulink并选择一个模型模板。
或者,如果您已经打开了Library Browser,请点击New Model按钮。
有关创建模型的其他方法,请参阅创建模型。
•打开一个现有模型。
要打开最近使用的模型,请在MATLAB Home选项卡上点击Simulink。
matlab的simulink简易⼊门知识Simulink的扩展模块库SimPowerSystems——电⼒电⼦系统的建模和仿真⼯具SimPowerSystems是在Simulink环境下进⾏电⼒电⼦系统建模和仿真先进⼯具。
SimPowerSystems是Simulink下⾯的⼀个专⽤模块库,包含电⽓⽹络中常见的元器件和设备,以直观易⽤的图形⽅式对电⽓系统进⾏模型描述。
模型可与其它Simulink模块的相连接,进⾏⼀体化的系统级动态分析。
⼀、SimPowerSystems专⽤模块库的特点:1. 使⽤标准电⽓符号进⾏电⼒系统的拓扑图形建模和仿真;2. 标准的AC和DC电机模型模块;变压器;传输线;信号和脉冲发⽣器;HVDC控制;IGBT模块和⼤量设备模型,有断路器,⼆极管,IGBT,GTO,MOSFET和晶闸管;3. 使⽤Simulink强有⼒的变步长积分器和零点穿越检测功能,给出⾼度精确的电⼒系统仿真计算结果4. 为快速仿真和实时仿真提供了模型离散化⽅法;5. 提供多种分析⽅法,可以计算电路的状态空间表达、计算电流和电压的稳态解、设定或恢复初始电流/电压状态、电⼒机械的潮流计算;6. 提供了扩展的电⽓系统⽹络设备模块,如电⼒机械,功率电⼦元件,控制测量模块和3相元器件;7. 提供36个功能演⽰模型,可直接运⾏仿真;8. 提供详细的⽂档,完整的描述了各个模块和使⽤⽅法,还有5个详细的案例。
⼆、SimPowerSystems专⽤模块库的强⼤功能:(⼀)SimPowerSystems中的模块SimPowerSystems中模块的数学模型基于成熟的电磁和机电⽅程,⽤标准的电⽓符号表⽰。
它们可以同标准的Simulink模块⼀起使⽤建⽴包含电⽓系统和控制回路的模型。
连接通过与SimPowerSystems提供的测量模块实现。
SimPowerSystems拥有近100个模块,分别位于7个⼦模块库中。
这些库模块涵盖了以下应⽤范围:1. 电⽓⽹络(Electrical Sources & Elements)RLC⽀路和负载,π型传输线,线性和饱和变压器,浪涌保护,电路分离器,互感,分布参数传输线,3相变压器(2个和3个绕组),AC和DC电压源,受控电压源和受控电流源。
要构建模型,可以使用Simulink® Editor 和Library Browser。
启动 MATLAB 软件启动 Simulink 之前,请先启动 MATLAB®。
请参阅启动和关闭(MATLAB)。
配置 MATLAB 以启动 Simulink您在 MATLAB 会话中打开第一个模型时需要的时间比打开后续模型长,因为默认情况下,MATLAB 会在打开第一个模型时启动 Simulink。
这种即时启动 Simulink 的方法可以缩短 MATLAB 启动时间,避免不必要的系统内存占用。
要快速打开第一个模型,您可以配置 MATLAB,在它启动时同时启动 Simulink。
要启动 Simulink 而不打开模型或 Library Browser,请使用start_simulink。
根据 MATLAB 的启动方式,恰当使用此命令:∙在 MATLAB startup.m文件中∙在操作系统命令行中,使用matlab命令和-r开关例如,要在运行 Microsoft®Windows®操作系统的计算机上启动 MATLAB 时启动 Simulink,请创建具有以下目标的桌面快捷方式:matlabroot\bin\win64\matlab.exe -r start_simulink在 Macintosh 和Linux®计算机上,可在启动 MATLAB 时使用以下命令启动Simulink 软件:matlab -r start_simulink打开 Simulink Editor要打开 Simulink Editor,您可以:∙创建一个模型。
在 MATLAB 的Home选项卡上,点击Simulink并选择一个模型模板。
或者,如果您已经打开了 Library Browser,请点击New Model按钮。
有关创建模型的其他方法,请参阅创建模型。
∙打开一个现有模型。
要打开最近使用的模型,请在 MATLAB Home选项卡上点击Simulink。
Simulink使用入门下面简要的介绍一下,如何使用Simulink进行建模和仿真实验:1.启动matlab之后,在命令窗口中输入命令“Simulink”或者单击工具栏上的Simulink图标,打开Simulink模块库窗口。
如图1所示。
图1 Simulink模块库窗口2.在Simulink模块库窗口中单击菜单项“File/New/Model”,就可以新建一个Simulink模型文件。
如图2所示。
图2 Simulink 模型文件3.在2中所建立的Simulink文件窗口中单击“File/Save as”,可以修改文件名,并把文件保存在自己所要保存的路径下。
4.双击Communications Blockset,该模块库包含了通信系统中常用的功能模块:Channels(传输信道),Comm Sources(信源),Comm Sink(信宿),Source Cording(信源编码),Modulation(调制),等等。
如图3所示。
图3 通信工具箱里的功能模块5.在Simulink基础库中找到自己需要的模块,选取该模块,直接拖动到新建模型窗口中的适当位置,或者选取该模块后,右击鼠标,“Add to…”加到所建模块窗口中。
图4中,把信号发生器放到了amn中。
图4 利用模块库建立仿真模型6.如果需要对模型模块进行参数设置和修改,只需选中模型文件中的相应模块,单击鼠标右键,选取相应的参数进行修改,或者双击鼠标左键,进行修改。
还可以在选中模块之后通过拖动鼠标来修改模块的位置、大小和形状。
7.通过快捷菜单的其它选项还可以对模型的颜色、旋转、字体、阴影等属性进行设置,也可以对模型进行接剪切、拷贝或删除。
8.模块外部的大于符号“>”分别表示信号的输入输出节点,为了连接两个模型的输入输出,可以将鼠标置于节点处,这时鼠标显示为十字,拖动鼠标到另一个模块的端口,然后释放鼠标的按钮,则形成了带箭头的连线,箭头的方向表示信号的流向。
simulink⼊门教程S i m u l i n k⼊门教程-CAL-FENGHAI.-(YICAI)-Company One1Simulink?快速⼊门启动Simulink软件要构建模型,可以使⽤ SimulinkEditor 和 Library Browser。
启动MATLAB软件启动 Simulink 之前,请先启动 MATLAB。
请参阅启动和关闭(MATLAB)。
配置MATLAB以启动Simulink您在 MATLAB 会话中打开第⼀个模型时需要的时间⽐打开后续模型长,因为默认情况下,MATLAB 会在打开第⼀个模型时启动 Simulink。
这种即时启动Simulink 的⽅法可以缩短 MATLAB 启动时间,避免不必要的系统内存占⽤。
要快速打开第⼀个模型,您可以配置 MATLAB,在它启动时同时启动 Simulink。
要启动 Simulink ⽽不打开模型或 Library Browser,请使⽤?start_simulink。
根据 MATLAB 的启动⽅式,恰当使⽤此命令:在 MATLAB?⽂件中在操作系统命令⾏中,使⽤matlab命令和-r开关例如,要在运⾏ MicrosoftWindows操作系统的计算机上启动 MATLAB 时启动Simulink,请创建具有以下⽬标的桌⾯快捷⽅式:matlabroot\bin\win64\ -r start_simulink在 Macintosh 和?Linux计算机上,可在启动 MATLAB 时使⽤以下命令启动Simulink 软件:matlab -r start_simulink打开SimulinkEditor要打开 Simulink Editor,您可以:创建⼀个模型。
在 MATLAB 的?Home选项卡上,点击Simulink并选择⼀个模型模板。
或者,如果您已经打开了 Library Browser,请点击?New Model按钮。
有关创建模型的其他⽅法,请参阅创建模型。
Simulink入门教程北京索为高科系统技术有限公司雒海涛2011-02-12一、simulink简介Simulink是MATLAB中的一种交互式工具,完全支持图形用户界面,无需考虑算法的实现,主要针对创造性算法和模块结构的设计。
基本的工作流程为:二、simulink启动Simulink可以通过三种方式启动,在matlab命令行输入simulink;点击matlab工具条上simulink图标;在matlab桌面开始菜单启动。
分别如下图所示:三、simulink基本环境介绍上图是simulink的基本界面环境,通过该界面可以新建simulink模型,点击工具条上的new 按钮,或者通过菜单Files-new-model来新建一个模型,模型界面如下:模型窗口由菜单、工具栏、模型浏览器窗口、模型框图窗口以及状态栏组成。
1、工具栏2、菜单菜单名菜单项功能FileNew——Model 新建模型Model properties 模型属性Preferences SIMULINK 界面的默认设置选项Print… 打印模型Close 关闭当前Simulink 窗口Exit MATLAB 退出MATLAB 系统EditCreate subsystem 创建子系统Mask subsystem… 封装子系统Look under mask 查看封装子系统的内部结构Update diagram 更新模型框图的外观ViewGo to parent 显示当前系统的父系统Model browser options 模型浏览器设置Block data tips options 鼠标位于模块上方时显示模块内部数据Library browser 显示库浏览器Fit system to view 自动选择最合适的显示比例Normal 以正常比例(100%)显示模型SimulationStart/Stop 启动/停止仿真Pause/Continue 暂停/继续仿真Simulation Parameters… 设置仿真参数Normal 普通Simulink 模型Accelerator 产生加速Simulink 模型FormatText alignment 标注文字对齐工具Filp name 翻转模块名Show/Hide name 显示/隐藏模块名Filp block 翻转模块Rotate Block 旋转模块Library link display 显示库链接Show/Hide drop shadow 显示/隐藏阴影效果Sample time colors 设置不同的采样时间序列的颜色Wide nonscalar lines 粗线表示多信号构成的向量信号线Signal dimensions 注明向量信号线的信号数Port data types 标明端口数据的类型Storage class 显示存储类型ToolsData explorer… 数据浏览器Simulink debugger… Simulink 调试器Data class designer 用户定义数据类型设计器Linear Analysis 线性化分析工具四、simulink常用模块介绍1.输入信号源模块库(Sources)2.接收模块库(Sinks)3.连续系统模块库(Continuous)4.离散系统模块库(Discrete)5.信号路线模块(Signal Routing)6.端口和子系统模块组(Ports&Subsystem)7.数学运算模块(Math Operations)8.查询表模块组(Look-Up Tabels)9.非连续函数模块组(Discontinuous)10.用户自定义模块(User-Defined Functions)五、Simulink文件操作1.新建文件新建仿真模型文件有几种操作:●在MATLAB 的命令窗口选择菜单“File”>“New”>“Model”。