Simulink Is Started from the MATLAB Command Prompt by Entering the Following Command

Total Page:16

File Type:pdf, Size:1020Kb

Simulink Is Started from the MATLAB Command Prompt by Entering the Following Command

SIMULINK – Module 1 Start Simulink at the MATLAB command prompt by entering the following command: simulink

Alternatively, you can hit the New Simulink Model button at the top of the MATLAB command window as shown below:

When it starts it brings in the Simulink Library Browser window. It outlines a list of commonly used blocks that are available for simulating a system.

Basic features: (at the leftmost column) Some of them are not available (not loaded). Let’s start our work with a simple introduction. Click Ctrl+N or go to file and click on New. A new workspace will appear where required blocks from Simulink library would be dragged in to generate our simulation environment. Suppose, we want to find out the solution of a differential equation like

d 3 y d 2 y dy a3  a2  a1  a0 y  f ( t ) … (1) dt dt2 dt where ai s are real coefficients (given). The initial values of the derivatives are also given.

We can visualize this problem logically as a machine that does the following:

Input TransferTransfer Output functionfunction

In our case, input function is f ( t ), output function is y( t ) that we have to find.

Let y( t )  est is a possible solution of the differential equation. Substituting this in (1), we get

3 2 st ( a3s  a2s  a1s  a0 )e  f ( t )

f ( t ) y( t )  est  or the output 3 2 ( a3s  a2s  a1s  a0 )  H( s ) f ( t ) where H( s ) is the transfer function. Note the form of our transfer function; it’s an inverse polynomial in s built with the coefficients of the differential equation.

1 H( s )  In our case, 3 2 ( a3s  a2s  a1s  a0 ) Our first task is to solve a problem like this. The steps are shown below:

1. Create a new workspace. 2. On the left column of simulink library, go to simulink and find the button ‘sources’. Click on it. On the right, various source functions will appear. Select the one marked ‘sine function’. Drag that source button in your workspace. 3. Next, click on the ‘continuous’ button. On the right, select the ‘Transfer Fcn’, and drag it in your workspace. 4. Now you have two blocks in your work space. Click on the sine function so that it is chosen. Next, press the control and select the Transfer function block. If it works, you will see the sine function box is now connected to the transfer block. 5. Notice that the denominator of the transfer function has s  1 . We want to change it to a polynomial, say, 6s3  5s2  1. 6. Double click on the transfer function block and insert the new polynomial coefficients in the second row marked ‘denominator coefficient’. We insert [6 5 0 1] there, and click ok. Note the change in your transfer function block. 7. Under the ‘simulink’ column, click onto ‘sinks’. This would capture your output. Select the ‘scope’, drag it in the workspace, and connect it from the output of the transfer function block. 8. Check the connection. You should have the blocks connected as 9. Simulation time (default value 10.0) appears on the toolbar. You can change it to another value.

10. To run the simulation, click on the simulation button on the workspace tool bar. Hit the ‘start’ button now. When the simulation completes, the ‘ready’ message appears at the bottom of the workspace.

11. To view the result, double click on the scope block. A sketch of the output function will appear there.

We need to scale the output to appear it more nuanced. See the binocular on the toolbar of the scope? Click on it to have its scale adjusted. The output now appears as (after the binocular is selected for zooming in).

What if we want to change the simulation duration from 10 seconds to 50 seconds? We go to the workspace window and change the simulation run length from 10.0 to 50.0. After that we run the simulation again.

The output from the scope appears as To change the vertical scale we again click on the binocular.

Next try with different transfer function. What if we change it to 2s  1 H( s )  6s3  5s2  1 Click onto the transfer function block and change its numerator parameter row.

The output, after suitable scaling, appears as

Suppose now, we want to take the output of the original transfer function we used and return it to the transfer function via a negative feedback loop.

We would need the system to appear as Here, we tap the output line and send it to an amplifier with a gain 1. Its output is then sent to a summing node in the manner shown. The output of the summing node is returned to the transfer function block.

First, to tap from a line: Position your cursor on the line, and then drag with the right button of the mouse pressed. This would generate a tapped line.

To rotate a block, select the block and go to the format of the workspace toolbar. Use the flip or rotate tool to orientate your target block.

To change the properties of the summing block from   orientation (default) to   orientation (for negative feedback), click on the summing node and update the list of signs row.

The output from the new design appears to be To save the model as a try1.mdl go to the FILE in the workspace toolbar and then use the “saveas” or “save”.

Recommended publications