MATLAB/ Simulink
MATLAB/ Simulink
INTRODUCTION
Matlab Simulink is used for modeling and simulation of the systems. In simulink, system models are constructed with using block diagram methodology. All the tools and functions are consist in the Simulink Library. Simulink can be started with writting this commend on Matlab
Simulink Library
Use the Library Browser to browse and search Simulink block libraries for blocks to use in your models. You can also select from a list of your most frequently used blocks.
The Library Browser has a search box for searching for blocks or libraries whose names that contain the search term you specify.
The Most Frequently Used Blocks pane displays a list of the blocks you have added the most often.
(or ctrl+N)
New model:
As you build your model, you often copy blocks from Simulink block libraries or other libraries or models into your model window. To do this:
1. Open the appropriate block library or model window. 2. Drag the block to copy into the target model window. To drag a block, position the cursor over the block, then press and hold down the mouse button. Move the cursor into the target window, then release the mouse button.
You can also drag blocks from the Simulink Library Browser into a model window. You can also copy blocks by using the Copy and Paste commands from the Edit menu:
1. Select the block you want to copy. 2. Choose Copy from the Edit menu. 3. Make the target model window the active window. 4. Choose Paste from the Edit menu.
Simulink assigns a name to each copied block. If it is the first block of its type in the model, its name is the same as its name in the source window. For example, if you copy the Gain block from the Math library into your model window, the name of the new block is Gain. If your model already contains a block named Gain, Simulink adds a sequence number to the block name. When you copy a block, the new block inherits all the original block's parameter values.
The models can be saved with ctrl+s and can be opened with ctrl+o. Or to do these functions, file menu can be used.
Starting simulation
A classic block diagram model of a dynamic system graphically consists of blocks and lines (signals). The history of these block diagram models is derived from engineering areas such as Feedback Control Theory and Signal Processing. A block within a block diagram defines a dynamic system in itself. The relationships between each elementary dynamic system in a block diagram are illustrated by the use of signals connecting the blocks. Collectively the blocks and lines in a block diagram describe an overall dynamic system.
Simulink block diagrams define time-based relationships between signals and state variables. The solution of a block diagram is obtained by evaluating these relationships over time, where time starts at a user specified "start time" and ends at a user specified "stop time." Each evaluation of these relationships is referred to as a time step.
Signals represent quantities that change over time and are defined for all points in time between the block diagram's start and stop time.
The relationships between signals and state variables are defined by a set of equations represented by blocks. Each block consists of a set of equations. These equations define a relationship between the input signals, output signals and the state variables. Inherent in the definition of a equation is the notion of parameters, which are the coefficients found within the equation.
Before you can begin building your model, you must start Simulink and create an empty model. To create a new model: If Simulink is not running, enter simulink in the MATLAB Command Window to open the Simulink Library Browser. Select File > New > Model in the Simulink Library Browser to create a new model.
1.
2.
To construct a model, you first copy blocks from the Simulink Library Browser to the model window. To create the simple model in this chapter, you need four blocks:
1.Sine Wave To generate an input signal for the model 2.Integrator To process the input signal 3.Scope To visualize the signals in the model 4.Mux To multiplex the input signal and processed signal into a single scope
Arrange the blocks in the model to look like the following figure.
Notice that each block has angle brackets on one or both sides. These angle brackets represent input and output ports:
You connect the blocks in your model by drawing lines between output ports and input ports. To draw a line between two blocks: Position the mouse pointer over the output port on the right side of the the other block.
EXAMPLE1
M2 x2 =B2 (x1 x2 ) k 2 x2 B3 x2
Equations of Motion:
x1 =Ma M1 x1
1 1
(B1 B2 ) x1 M1
M2 x2
1
x2 =M2 (x1 x2 ) M2 x2 M3 x2
2 2 2
To get the parameters from a Simulink block : (In .mdl file) File > Model Properties > Callbacks > InitFcn
Connecting the blocks by drawing lines between output ports and input ports.