The Simulink® product is a software environment for modeling, simulating, and analyzing dynamic systems. Try building a simple model that drives an actuator with a sine wave and displays the actuator's position superimposed on the sine wave.
If you prefer to open the complete model shown below instead
of building it, enter
The following section (Create a Model) explains how to build a model on Windows® platforms. You can use this same procedure to build a model on Linux® platforms.
The section describes how to build the model. It does not describe how to set the configuration parameters for the model. See Configuration Parameters Dialog Box Overview. That topic describes the Configuration Parameters Dialog Box for models. If you do not set any configuration parameters, simulating models might cause warnings like:
Warning: Using a default value of 0.2 for maximum step size. The simulation step size will be equal to or less than this value. You can disable this diagnostic by setting 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics page of the configuration parameters dialog
button in the MATLAB Toolstrip
the MATLAB command line. The Simulink library browser appears.
Select New > Model from the File menu in the Library Browser. A new model window appears on your screen.
Add a Sine Wave block to the model.
Click Sources in the Library Browser to view the blocks in the Simulink Sources library.
Drag the Sine Wave block from the Sources library into the new model window.
Add a Linear Second-Order Actuator block to the model.
Click the symbol next to Aerospace Blockset in the Library Browser to expand the hierarchical list of the aerospace blocks.
In the expanded list, click Actuators to view the blocks in the Actuator library.
Drag the Linear Second-Order Actuator block into the model window.
Add a Mux block to the model.
Click Signal Routing in the Library Browser to view the blocks in the Simulink Signals & Systems library.
Drag the Mux block from the Signal Routing library into the model window.
Add a Scope block to the model.
Click Sinks in the Library Browser to view the blocks in the Simulink Sinks library.
Drag the Scope block from the Sinks library into the model window.
Resize the Mux block in the model.
Click the Mux block to select the block.
Hold down the mouse button and drag a corner of the Mux block to change the size of the block.
Connect the blocks.
Position the pointer near the output port of the Sine Wave block. Hold down the mouse button and drag the line that appears until it touches the input port of the Linear Second-Order Actuator block. Release the mouse button.
Using the same technique, connect the output of the Linear Second-Order Actuator block to the second input port of the Mux block.
Using the same technique, connect the output of the Mux block to the input port of the Scope block.
Position the pointer near the first input port of the Mux block. Hold down the mouse button and drag the line that appears over the line from the output port of the Sine Wave block until double crosshairs appear. Release the mouse button. The lines are connected when a knot is present at their intersection.
Set the block parameters.
Double-click the Sine Wave block. The dialog box that appears allows you to set the block's parameters.
For this example, configure the block to generate a 10 rad/s
sine wave by entering
10 for the Frequency parameter.
The sinusoid has the default amplitude of
0 specified by the Amplitude and Phase offset parameters.
Double-click the Linear Second-Order Actuator block.
In this example, the actuator has the default natural frequency
150 rad/s, a damping ratio
0.7, and an initial position
0 radians specified by the Natural frequency, Damping
ratio, and Initial position parameters.
You can now run the model that you built to see how the system behaves in time:
Double-click the Scope block if the Scope window is not already open on your screen. The Scope window appears.
Select Run from the Simulation menu in the model window. The signal containing the 10 rad/s sinusoid and the signal containing the actuator position are plotted on the scope.
Adjust the Scope block's display. While the simulation is running, right-click the y-axis of the scope and select Autoscale. The vertical range of the scope is adjusted to better fit the signal.
Vary the Sine Wave block parameters.
While the simulation is running, double-click the Sine Wave block to open its parameter dialog box.
You can then change the frequency of the sinusoid.
20 in the Frequency field.
Close the Sine Wave dialog box to enter your change. You can then
observe the changes on the scope.
Select Stop from the Simulation menu to stop the simulation.
Many parameters cannot be changed while a simulation is running. This is usually the case for parameters that directly or indirectly alter a signal's dimensions or sample rate. However, there are some parameters, like the Sine Wave Frequency parameter, that you can tune without stopping the simulation.
You can also modify and run a Simulink simulation from a script. By doing this, you can automate the variation of model parameters to explore a large number of simulation conditions rapidly and efficiently. For information on how to do this, see About Programmatic Simulation.