0% found this document useful (0 votes)
151 views149 pages

SIMULINK

The document provides instructions for using Simulink to model and solve a simple shopping problem. It describes: 1) Opening Simulink and getting a new model window. 2) Adding constant blocks to represent the number of items and renaming the blocks. 3) Connecting the blocks and changing parameter values. 4) Simulating the model to calculate the total number of items.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views149 pages

SIMULINK

The document provides instructions for using Simulink to model and solve a simple shopping problem. It describes: 1) Opening Simulink and getting a new model window. 2) Adding constant blocks to represent the number of items and renaming the blocks. 3) Connecting the blocks and changing parameter values. 4) Simulating the model to calculate the total number of items.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 149

Simulink

To Get into Simulink browser click at the


Simulink icon in the MATLAB desktop

Click here to open


Simulink browser
Simulink library browser opens as follows

Click here to get


new model window
New MODEL WINDOW opens as follows
Now let us take a simple problem with the
following data
Articles Numbers

Eraser 4
Pad 6
Tape 2

Calculate:

 Total number of items


The Blocks Needed For The Problem

 Three Constant Blocks


 One Sum Block
 One Display Block
Searching the blocks in the Simulink
Library Browser

Enter the name of the


block ‘constant’
in the library
browser

constant block is
highlighted as
shown
Similarly search
for other blocks
Model Window

Enter the name of the


block ‘constant’
in the library browser

Drag and Drop the Constant Block


from the Library Browser in to
the New Model Window
Similarly Drag and Drop Three Constant Block, Sum and
Display block into the New Model Window as per the
requirement of your problem.

Here the sum block will have


two ‘in' ports by default.
To add more ‘in' ports in Sum Block
 Double click the Sum Block the
following dialogue box appears.
 In the icon shape change it
rectangular.

 In the list of signs Add one


more ‘+’ symbol
to get three ‘in’ ports.
Now the Sum Block will appear as shown
below

Sum Block with


three ‘in’ ports
To rename the blocks click the text below in each block
and change the name

Click to save

Constant block renamed as Eraser.


Similarly other blocks are also renamed.
 Then save the model window
 The file will be saved with ‘.mdl’ as an extension
File name.
 To change the value of ‘Eraser’ block
 Double click the ‘Eraser’ block
 The dialogue box appears as shown below.
Changing the Parameters

 Change the constant value from 1 to 4


 Then click OK
Then the Model Window will appear as shown below
 Then click the Simulation from the Menu bar.
 And then click ‘start’ to run the Model.
 The output is displayed in the Display Block.

OUTPUT
Shopping Model
 Suppose you purchased 4 erasers at 25 cents each,
6 memo pads at 52 cents each, 2 rolls of tape at 99
cents of each and you need to calculate,

 The total number of items


 The total cost
 The average cost
Steps Involved in this Model
 Getting New Model Window
 Drag and Drop the required blocks
 Duplicating the blocks
 Changing the block labels
 Connecting the blocks
 Annotating the blocks
 Changing the parameter
 Saving the Model
 Simulating the Model
To get new model window

Click here to get the new


model window in the
Simulink library browser
Blocks Required
 3 constant blocks
 3 gain blocks
 2 sum blocks
 1 divide block and
 3 display blocks
 To bring a block to the workspace, just click and drag
the required block to the workspace.

Left click and drag the


Block into Model Window
Copying a Block within a Model

 Select the desired


block
 Right click on the
block
 Drag the copy to
the desired
position.
 Release the
mouse button,
completes the
copy operation.

After Releasing the


Mouse Button
After Copying the blocks the model will appear as
shown below
Changes in the Sum block
1)The number of input ports
2)Shape of the blocks

Double click here

Click here to change the shape

Increase the ‘+’sign here to


increase I/P port
After changing click ‘OK’
After changing the number input ports and the shape
the model will appear as shown below
Changing the Block Label

 Simulink supplies a default label for each


block in the model window
 For example, the Constant block will
have the default name “Constant”,
 The second Constant block will be
labeled “Constant1” and so on.
 Click the block label, an
editing cursor will appear
 Position the cursor any
where in the label by
clicking
 You can move the cursor by
using the cursor movement
keys.

Positioning the Cursor


To Replace a Label
 Select the block label
 Double click it
 The label will be highlighted as
shown here
 Type the new label

Highlighting the Label After replacing the label


 To create multiple-line label
 Press enter at the end of each line.

Multiple-Line
After Changing the Names the Model will
appear as shown below
Connecting the Block

Connecting the Block

Just left-click and drag from the output port of a


Left click and drag the Outport
block to the inputOfport of the other
the Constant block
Block into
Inport of the Gain Block
After Connecting All Blocks the Model will appear as
shown below
Annotating the Blocks

 To add an annotation to your model, place the cursor


at an unoccupied area in your model window and
double click (left button).
 A small rectangular area will appear with a cursor
prompting for your input.
Annotation

Annotation Shopping Model


Changing the Parameter

Double click here

You will get this


dialog box
Enter the
value here
After Changing All the Parameters the
Model will appear as shown below
Saving the Model
Click here to Save the Model
Save as dialog box open’s as follows

Enter the filename here


Simulating the Model

Click here to Simulate the


model
Result of Shopping Model will
appears as shown below
SUB SYSTEMS
Creating a Subsystem by Grouping Existing
Blocks
(Take previous example)
Select the blocks you want as Subsystem
(Using left click and drag)
Right click on any of the highlighted blocks

Click
Create Subsystem
Simulink Model Opens as Shown Below
with the Created Subsystem
Created Subsystem
To Edit a Subsystem
Select the Subsystem

Double Click
Subsystem
Subsystem appears as shown below

You can make


Changes in any of
the Blocks
Masking
Let us take the simple problem with the
following data
Articles Numbers

Eraser 4
Pad 6
Tape 2

Calculate:

 Total number of items


 The model is

Click here to Save


Enter File Name
Click here to Save
Creating a Mask
 First build the Subsystem

Select the Blocks


Right click here

Then choose
Create Subsystem
After creating the Subsystem the Model
appears as shown below
Masking the Block / Subsystem

Right click
The Subsystem Block

Choose
Mask Subsystem
Mask Editor opens as follows

Select Parameters
Now Mask Editor opens as follows

Click this icon to


Add Parameters
Enter the Variable

Enter the variable Name

Enter the Variable


Variable Name and Variable
Similarly enter other variable used by
add parameter

Click Here
Mask Editor opens as follows

Enter Comments
Here
Click Apply and OK
Now Simulink Model appears as shown
below

To enter the Parameter


Double click here
Now right click on the subsystem and select look
under mask

Enter
the
variable
name

Outport
Double click on the subsystem and the
Parameters Block opens as follows
Enter the Value

Enter the number of Eraser,


Pad and Tape Value Click OK
Simulate the Model

Click here to
Start Simulation
Display the Output

Result
Undo the Mask

Right Click and


Choose Edit Mask
Mask Editor opens as follows

Click Unmask
Then Click OK
Simulink Model appear as
shown below

Double Click Here


Open Subsystem block as shown below
And you can do any change needed

Outport
 Let us consider a Subsystem model for the equation y =
mx + c
 The model is

Click here to Save


Save the Model

Enter File Name


Click here to Save
Creating a Mask
 First build the Subsystem

Select the Blocks


Right click here

Enter the
variable
names

Then choose
Create Subsystem
After creating the Subsystem the Model
appears as shown below
Masking the Block / Subsystem

Right click
The Subsystem Block

Choose
Mask Subsystem
Mask Editor opens as follows

Select Parameters
Now Mask Editor opens as follows

Click this icon to


Add Parameters
Enter the Variable

Enter the variable Name

Enter the Variable


Variable Name and Variable
Similarly enter other variable used

Click Here
Mask Editor opens as follows

Enter Command
Here
Click Apply and OK
Now Simulink Model appears as shown
below

To enter the Parameter


Double click here
Enter the Value

Enter the Slope and


Click OK
Intercept Value
Simulate the Model

Click here to
Start Simulation
Display the Output

Result
Undo the Mask

Right Click and


Choose Edit Mask
Mask Editor opens as follows

Click Unmask
Then Click OK
Simulink Model appear as
shown below

Double Click Here


Initial condition, Sampling time,
Simulation time
 Example

The initial loan balance is $15,000, the interest rate is


1% per month(12% annual interest), and the monthly
payment is $200. Compute the loan balance after 100
payments.
 Solution

 The Unit Delay block Initial condition is the initial


loan balance (15000)
 The Unit Delay block Sample time is set to 1(for
one month)
 Set type to Fixed-step, solver to discrete (no
continuous states).
 After running the simulation, the Display block
shows the ending balance.
Model for the above problem

Double click here

Unit Delay
The dialogue box opens as shown below

Set the initial condition


And sample time
After setting the initial condition and Sample time the
dialogue box will appear shown below

Click OK
Set the simulation time to 100

Select configuration
parameters
The configuration parameter dialogue box appear as
shown below
Set Simulation
Stop time to 100
Set Type to
Fixed-step

Set Solver to
Discrete
(no continuous states)

Click OK
Simulate the Model
Simulation time

Click here to
Start Simulation

Click to open the Model


Scope output of the Model
Explanation

 At the end of each month, the loan balance b(k) is sum


of the balance at beginning of the month [b(k-1)] and
interest for the month [ib(k)],less the end-of-month
payment p(k).Thus balance at the end of month k is
b(k)=r b(k-1)-p(k)
Where r=i+1, and i is monthly interest rate.
Block diagram

z-1

ki
 Sample time
it is a scalar interval between samples or a two-
element vector consisting of the interval between
samples and an offset or time skew.
Other Manipulations
Resizing a Block
 Open a block library and
drag Gain block to the
model window.
 We’ve set the block
parameter gain to the value
1227.86
 Because this value will not
fit on the block icon
 The displayed value is -K-
To resize a Block
 Select the block,
causing the handles to
appear.
 Click the desired
handle, and continue to
depress the mouse
button.
 Drag the handle to resize the
block
 Notice that the cursor changes
shape, confirming that you have
grasped the resize handle

 Release the mouse button. Now


the block icon is large enough to
display the value of Gain
Rotating a Block

 Select a block,

Click Here

 Then choose
Format : Rotate from
the menu bar.
 The block will rotate
90 degrees
clockwise.
 Shortcut key : ctrl r
Deleting Blocks
 To delete a block, Select a Block and the
press the Delete key.

 Alternative Method
 Select the block, then choose Edit :Clear
from the menu bar.
 Select the block and place it on the clip
board, then choose Edit :Cut or press
Control-X.
Changing Label Location
 Select the block
 Then choose Format :Flip
Name from the Menu bar Or
 Click the name and drag it to
the desired position.
 If the block is rotated 90° the
block label will be to the left
or the right of the block.
Hiding a Label
 It is some times desirable to hide the
name of a block.
 For example, the shape of a Gain
block uniquely identifies the purpose
of the block, and the value of gain
displayed on the block.
 A cluttered model might be improved
by hiding the names of the gain
blocks.
To hide the name
 Select the block, and choose
Format :Hide Name
 This does not change the name of
the block in any way - It simply
makes the name invisible.
Select Hide Name
 If the name of a block is hidden, to
show the name. Name
 Select the block, then choose
Format :Show Name from the
Menu bar.
Adding a Drop Shadow
 If you want to call special
attention to a block, you can
apply a drop shadow.
 Select the block
 Choose Format :Show Drop
Shadow from the menu bar.
 Format :Hide Drop Shadow is
used to remove the drop
shadow from the block

Drop shadow
Using Colour
 You can set the foreground and background
colour for each block or a selected set of
blocks.
 Foreground colour is the colour of a block’s
outline and labels.
 Background colour is the colour of the body of
the block.
To Change Colour of a Block

 To change foreground and


background colour

 Select the block

 Choose Format:Foreground
Color or Format
 :Background Color

Foreground color
Background color
 To change screen colour

 Click the empty space

 Format :Screen Color.

Screen color
SIGNAL LINES
Moving a Segment
 To move a line
segment, click the
segment.

Line Segment

 The cursor will change


shape.
 Keep the mouse button
clicked and drag the segment
to the desired location.

 Release the mouse button .


Moving a Vertex
 To move a vertex
 Click the vertex.

Vertex
 The cursor will
change the shape
to circle.

Cursor Shape
 Drag the vertex to the
desired location.

Dragging

 Release the mouse


button to complete the
operation.
Splitting a Signal Line
 To split a line, Select the
line segment.
 Press shift key, then click
the line at the point at
which you wish to split it
Line Segment
 The cursor will change
the shape to a circle, and
the segment will split into
two segments.

Cursor Shape
 Drag the new vertex
to the desired
location.

 Release the mouse


button to complete
the operation.
Labeling a Signal Line

 Each signal line may have a label.


 The label can be positioned at either end of
the signal line and on either side.
 Signal line labels, unlike block labels, do not
have to be unique.
Labeling the Signal Line
 To add a label to a signal line
 Double click the line, causing an editing
cursor to appear near the line.
 Be sure that you click the line itself, not
just near the line.
 Double clicking away from a line will
result in an annotation.
After double clicking the signal line the Editing
cursor will appear as shown below

Double click Signal Line


Editing Cursor appears
 Enter the label. As with
block labels, press enter at
the end of each line to enter
a label consisting of more
than one line of text.
Signal Line Label

 Click away from the line to


complete entering the label.
 The label will snap to a
position near the center of
the line.
Moving or Copying a Signal Line Label

 You can move a signal line


label to either end or middle of
the signal line.
 To move signal line label, click
the label.
Signal Line Label

 Drag the label to the desired


location near the signal line.

Dragging
Signal Line Label
 Release the mouse
button. The label will
snap into position.

Moved
Signal Line Label
 To copy a signal line
label press the control
key while dragging the
label to the new
position.

Copied
Signal Line Label
Signal Label Propagation
 Signal line labels can propagate through several
blocks in the connections block library.
 Among these are the Mux and Demux, Goto and
From, and Inport and Outport blocks.
 Signal line propagation provides accurate means with
which to determine the exact content of a signal line.
 This makes a model easier to understand and can
also be useful in debugging.
 For example, a model in
which two scalar signals
produced by constant blocks
are combined to form vector
signal by a Mux block.
 The Demux block splits the
vector signal into two scalar
signals that are displayed by
Display blocks.

Note that the model is shown before running the simulation,


First label the source signal lines. Here the outputs of
constant blocks KA and KB are labeled A and B.
 Label each signal line
onto which you want the
labels propagated with
the single character <.
 All three signal lines
configured to propagate
the labels.
 Choose Edit : Update Diagram Signal Line Label
from the Menu bar of the Model
window
 The signal leaving Mux block
contains two signals, so the label
changed to <A,B>.
 The Demux block separates the
vector signal into components, so
the signal lines leaving it each
contain only one signal .
 The propagated labels are
enclosed in angle brackets to
distinguish them from simple
labels

propagated
Signal Line Label
ANNOTATIONS
 You can add annotations to model to make it
easier to understand.
 You can also change the font used in an
annotation to add emphasis
Adding Annotation
Editing Cursor
 Double click the location where
you want the center of an
annotation to be.
 An editing cursor will appear.
 Enter the annotation. Press enter
at the end of each line of multiple-
line annotation.
 Click away from the annotation to
complete the process.

Annotation
SIMULINK

 SIMULINK (Simulation and Link) is an


extension of MATLAB.

 It is a software package for modeling, simulating,


and analyzing dynamic systems.
Features of a Subsystem

 Reduces the number of blocks


 Allows to keep functionally related blocks together
MASKING

 Masking is a Simulink capability that


extends the concept of abstraction.
 Masking permits us to treat a subsystem
as if it were a simple block.
Operations in Masking

 The Mask Editor


 Defining an Icon
 Defining the Dialog
 Defining the Block Documentation
Features of Masking
 Replaces many dialog boxes in a subsystem into a
single dialog box
 Provides more descriptive and helpful user interface
 Prevent unintended modifications by hiding the
contents

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy