1 Matlab Simulink Tutorial 1 -1st Order System

  • Upload
    5wolf7

  • View
    230

  • Download
    0

Embed Size (px)

Citation preview

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    1/24

    A Simulink tutorial

    Getting Started with Matlab Simulink

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    2/24

    Controls and Instrumentation Slide 2

    Before we start

    You should have access to Matlab andSimulink software through the laboratorycomputers in Fryklund Hall.

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    3/24

    Controls and Instrumentation

    [All Program] Matlab Launch Simulink

    Slide 3

    Launch Matlab Simulink

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    4/24

    Controls and Instrumentation Slide 4

    Create a new model

    Click the new-modelicon in the upper left

    corner to start a newSimulink file

    Select and expand theSimulink icon to obtainelements of the model

    Create a new model from the Simulink Library window Browser

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    5/24

    Controls and Instrumentation Slide 5

    Workspace in Simulink

    Library of elements Model is created in this window

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    6/24

    Controls and Instrumentation Slide 6

    Save your Model

    You might create anew folder to save

    your Simulink files.

    The saved Simulinkfiles should have .mdlsuffix with the file

    names.

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    7/24

    Controls and Instrumentation Slide 7

    Example 1: A Simple Model

    Build a Simulink model that solves the differentialequation

    Initial condition:

    The analytical solution

    First, sketch a block diagram of this mathematical

    model (equation) in Simulink.

    ( ) ( ) 0y t y t

    ( ) 0.01 t 0t

    y t e

    y(0) = 0.01

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    8/24

    Controls and InstrumentationMFGE 363 Slide 8

    Block Diagram in Simulink

    The differential equation:

    Output is the solution of the differential equationy (t)

    ( ) ( ) 0y t y t

    yy

    s

    10

    (input)

    y (t)

    (output)

    (0) 0.01y

    integrator

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    9/24

    Controls and Instrumentation Slide 9

    Block Diagram in Simulink

    First, solve for the term with highest-orderderivative

    Make the left-hand side of this equation theoutput of a summing block as shown in the blockdiagram on the next slide

    ( ) 0 ( )y t y t

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    10/24

    Controls and Instrumentation Slide 10

    Block Diagram for the DEQ

    ( ) ( ) 0 can be re-arrange as

    ( ) 0 ( )

    y t y t

    y t y t

    ( )y t ( )y t

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    11/24

    Controls and Instrumentation Slide 11

    Select an Input Block

    Drag a Constant block fromthe Sourceslibrary to themodel window

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    12/24

    Controls and Instrumentation Slide 12

    Select a SUM Block

    Drag a SUM block from theMath Operationslibrary tothe model window

    Math Operations

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    13/24

    Controls and Instrumentation Slide 13

    Select an Integrator Block

    Drag an Integratorblockfrom the Continuouslibraryto the model window

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    14/24

    Controls and Instrumentation Slide 14

    Select a Scope Block

    Drag a Scopeblock from theSinkslibrary to the modelwindow

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    15/24

    Controls and Instrumentation Slide 15

    Select a Gain Block

    Drag a Gain block from theMath Operationlibrary to themodel window

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    16/24

    Controls and Instrumentation Slide 16

    Connect Blocks with Signals

    Place your cursor on theoutput port (>) of theConstantblock

    Left click the mouse and

    drag from the Constantoutput port to the Suminput

    Drag from the SUMoutput to the input of

    the integrator input port Connect the scope and

    gain blocks

    Arrows indicate the directionof the signal flow.

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    17/24

    Controls and Instrumentation Slide 17

    Select Simulation Parameters

    Double-click on theConstantblock to setConstant value = 0.

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    18/24

    Controls and Instrumentation Slide 18

    Select Simulation Parameters

    Change the sign of thesum block to +- in thefield of List of signs

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    19/24

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    20/24

    Controls and Instrumentation Slide 20

    Select Simulation Parameters

    Double-click onthe Gain block toset gain = 1.

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    21/24

    Controls and Instrumentation Slide 21

    Select Simulation Parameters

    Double-click on theScopeto view thesimulation results

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    22/24

    Controls and Instrumentation Slide 22

    Run the Simulation

    In the modelwindow, from theSimulationpull-down menu, selectStart

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    23/24

    Controls and Instrumentation Slide 23

    View the Simulation

    Click on Auto-scale andview the output y (t)inthe Scopewindow. Auto scale

  • 8/3/2019 1 Matlab Simulink Tutorial 1 -1st Order System

    24/24

    Controls and Instrumentation Slide 24

    Simulation Results

    To verify that this plotrepresents the solution tothe problem, solve the

    equation analytically.

    The analytical result,

    matches the plot (thesimulation result) exactly.

    ( ) 0.01 t 0t

    y t e