+ All Categories
Home > Documents > Simulink Present

Simulink Present

Date post: 06-Apr-2018
Category:
Upload: zx112
View: 221 times
Download: 0 times
Share this document with a friend
95
Simula tion in Simulink Simul a tion in Simulink Bruce A. Desmarais Odum Institute for Research in Social Science February 14, 2009
Transcript
Page 1: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 1/95

Simulation in Simulink

Simulation in Simulink

Bruce A. Desmarais

Odum Institute for Research in Social Science

February 14, 2009

Page 2: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 2/95

Simulation in Simulink

Introduction

Welcome!

Who am I?

Page 3: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 3/95

Simulation in Simulink

Introduction

Welcome!

Who am I?

Bruce Desmarais; Red Sox Fan and PhD student in the UNC PoliSci Dept.

Page 4: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 4/95

Simulation in Simulink

Introduction

Welcome!

Who am I?

Bruce Desmarais; Red Sox Fan and PhD student in the UNC PoliSci Dept.

Extensive experience with matrix algebra, simulation and statistical

computing in Matlab and other software/languages

Page 5: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 5/95

Simulation in Simulink

Introduction

Welcome!

Who am I?

Bruce Desmarais; Red Sox Fan and PhD student in the UNC PoliSci Dept.

Extensive experience with matrix algebra, simulation and statistical

computing in Matlab and other software/languages

No formal training in the instruction of Matlab(comments/suggestions will be much appreciated)

What will we cover?

S S

Page 6: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 6/95

Simulation in Simulink

Introduction

Welcome!

Who am I?

Bruce Desmarais; Red Sox Fan and PhD student in the UNC PoliSci Dept.

Extensive experience with matrix algebra, simulation and statistical

computing in Matlab and other software/languages

No formal training in the instruction of Matlab(comments/suggestions will be much appreciated)

What will we cover?

Basic System design and Simulation in Simulink

Page 7: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 7/95

Simulation in Simulink

Page 8: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 8/95

Simulation in Simulink

Introduction

Welcome!

Who am I?

Bruce Desmarais; Red Sox Fan and PhD student in the UNC PoliSci Dept.

Extensive experience with matrix algebra, simulation and statistical

computing in Matlab and other software/languages

No formal training in the instruction of Matlab(comments/suggestions will be much appreciated)

What will we cover?

Basic System design and Simulation in Simulink

Manipulation of Simulink Model files

Simulink Interface with Matlab

Simulation in Simulink

Page 9: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 9/95

Simulation in Simulink

Introduction

Welcome!

Who am I?

Bruce Desmarais; Red Sox Fan and PhD student in the UNC PoliSci Dept.

Extensive experience with matrix algebra, simulation and statistical

computing in Matlab and other software/languages

No formal training in the instruction of Matlab(comments/suggestions will be much appreciated)

What will we cover?

Basic System design and Simulation in Simulink

Manipulation of Simulink Model files

Simulink Interface with Matlab

Examples

Simulation in Simulink

Page 10: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 10/95

Simulation in Simulink

Introduction

What is Simulink?

Simulation in Simulink

Page 11: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 11/95

Simulation in Simulink

Introduction

What is Simulink?

Graphical extension to MATLAB for modeling and simulationof systems; Similar to Winbugs

Simulation in Simulink

Page 12: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 12/95

Introduction

What is Simulink?

Graphical extension to MATLAB for modeling and simulationof systems; Similar to Winbugs

Systems drawn on screen as block diagrams

Simulation in Simulink

Page 13: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 13/95

Introduction

What is Simulink?

Graphical extension to MATLAB for modeling and simulationof systems; Similar to Winbugs

Systems drawn on screen as block diagrams

Integrated with MATLAB

Simulation in Simulink

Page 14: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 14/95

Introduction

What is Simulink?

Graphical extension to MATLAB for modeling and simulationof systems; Similar to Winbugs

Systems drawn on screen as block diagrams

Integrated with MATLAB

Combines intuitive graphical-user interface with excellentspeed and storage capabilities

Simulation in Simulink

Page 15: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 15/95

Introduction

What is Simulink?

Graphical extension to MATLAB for modeling and simulationof systems; Similar to Winbugs

Systems drawn on screen as block diagrams

Integrated with MATLAB

Combines intuitive graphical-user interface with excellentspeed and storage capabilities

Is free to you!! (or included in tuition; however you want tolook at it)

Simulation in Simulink

Page 16: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 16/95

Introduction

New Model...First Steps

Open Matlab

Simulation in Simulink

Page 17: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 17/95

Introduction

New Model...First Steps

Open Matlab

Type simulink

Simulation in Simulink

Page 18: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 18/95

Introduction

New Model...First Steps

Open Matlab

Type simulink

Simulink library browser pops up

Simulation in Simulink

I

Page 19: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 19/95

Introduction

New Model...First Steps

Open Matlab

Type simulink

Simulink library browser pops up

Start a new model file Crtl + N

Simulation in Simulink

I

Page 20: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 20/95

Introduction

New Model...First Steps

Open Matlab

Type simulink

Simulink library browser pops up

Start a new model file Crtl + N

The blank file is where model will be built..save it

Simulation in Simulink

Introduction

Page 21: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 21/95

Introduction

New Model...First Steps

Open Matlab

Type simulink

Simulink library browser pops up

Start a new model file Crtl + N

The blank file is where model will be built..save it

Libraries contain building blocks

Simulation in Simulink

Basics

Page 22: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 22/95

Basics

Blocks

Model is a collection of blocks connected by lines. There are anumber of different classes of blocks:

Simulation in Simulink

Basics

Page 23: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 23/95

Basics

Blocks

Model is a collection of blocks connected by lines. There are anumber of different classes of blocks:

Sources: Used to generate signals

Simulation in Simulink

Basics

Page 24: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 24/95

Basics

Blocks

Model is a collection of blocks connected by lines. There are anumber of different classes of blocks:

Sources: Used to generate signals

Sinks: Used to output

Simulation in Simulink

Basics

Page 25: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 25/95

s cs

Blocks

Model is a collection of blocks connected by lines. There are anumber of different classes of blocks:

Sources: Used to generate signals

Sinks: Used to output

Discrete: Linear, discrete-time system elements (transfer-functions)

Simulation in Simulink

Basics

Page 26: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 26/95

Blocks

Model is a collection of blocks connected by lines. There are anumber of different classes of blocks:

Sources: Used to generate signals

Sinks: Used to output

Discrete: Linear, discrete-time system elements (transfer-functions)

Nonlinear: Arbitrary nonlinear operators

Simulation in Simulink

Basics

Page 27: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 27/95

Blocks

Model is a collection of blocks connected by lines. There are anumber of different classes of blocks:

Sources: Used to generate signals

Sinks: Used to output

Discrete: Linear, discrete-time system elements (transfer-functions)

Nonlinear: Arbitrary nonlinear operators

Connections: Multiplex, Demultiplex

Simulation in Simulink

Basics

Page 28: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 28/95

Blocks

Model is a collection of blocks connected by lines. There are anumber of different classes of blocks:

Sources: Used to generate signals

Sinks: Used to output

Discrete: Linear, discrete-time system elements (transfer-functions)

Nonlinear: Arbitrary nonlinear operators

Connections: Multiplex, Demultiplex

Simulation in Simulink

Basics

Page 29: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 29/95

Blocks

Model is a collection of blocks connected by lines. There are anumber of different classes of blocks:

Sources: Used to generate signals

Sinks: Used to output

Discrete: Linear, discrete-time system elements (transfer-functions)

Nonlinear: Arbitrary nonlinear operators

Connections: Multiplex, Demultiplex

Blocks have input and output terminals indicated by wedges pointing

towards and away from the block respectively. Lines transmit signals

from input to output.

Simulation in Simulink

Basics

Page 30: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 30/95

Lets build our first model

Click on Source

Simulation in Simulink

Basics

Page 31: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 31/95

Lets build our first model

Click on Source

Drag the radnom box into the left of the model

Simulation in Simulink

Basics

Page 32: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 32/95

Lets build our first model

Click on Source

Drag the radnom box into the left of the model

Produces a gaussian signal with set parameters.

Simulation in Simulink

Basics

Page 33: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 33/95

Lets build our first model

Click on Source

Drag the radnom box into the left of the model

Produces a gaussian signal with set parameters.

Return to library main, click on User Defined

Simulation in Simulink

Basics

Page 34: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 34/95

Lets build our first model

Click on Source

Drag the radnom box into the left of the model

Produces a gaussian signal with set parameters.

Return to library main, click on User Defined

Drag the Matlab Fcn into the model

Simulation in Simulink

Basics

Page 35: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 35/95

Lets build our first model

Click on Source

Drag the radnom box into the left of the model

Produces a gaussian signal with set parameters.

Return to library main, click on User Defined

Drag the Matlab Fcn into the model

Return to library main, click on Sinks

Simulation in Simulink

Basics

Page 36: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 36/95

Lets build our first model

Click on Source

Drag the radnom box into the left of the model

Produces a gaussian signal with set parameters.

Return to library main, click on User Defined

Drag the Matlab Fcn into the model

Return to library main, click on SinksDrag Scope into the model, connect all

Simulation in Simulink

Basics

Page 37: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 37/95

Block Manipulation

Blocks have many sorts of parameters

Simulation in Simulink

Basics

Page 38: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 38/95

Block Manipulation

Blocks have many sorts of parameters

To set a block’s parameters, right-click on a block and select theparameters option

Simulation in SimulinkBasics

Page 39: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 39/95

Block Manipulation

Blocks have many sorts of parameters

To set a block’s parameters, right-click on a block and select theparameters option

Our gaussian signal has mean and variance and seed parameters.Right click and set them to 0.5 and 1.5 respectively, be sure to noteor set seed in rng’s

Simulation in SimulinkBasics

Page 40: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 40/95

Block Manipulation

Blocks have many sorts of parameters

To set a block’s parameters, right-click on a block and select theparameters option

Our gaussian signal has mean and variance and seed parameters.Right click and set them to 0.5 and 1.5 respectively, be sure to noteor set seed in rng’s

The Matlab Function takes a function as a parameter with

vector-valued argument u . Lets set it to sin(u ) + 1.

Simulation in SimulinkBasics

Page 41: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 41/95

Block Manipulation

Blocks have many sorts of parameters

To set a block’s parameters, right-click on a block and select theparameters option

Our gaussian signal has mean and variance and seed parameters.Right click and set them to 0.5 and 1.5 respectively, be sure to noteor set seed in rng’s

The Matlab Function takes a function as a parameter with

vector-valued argumentu 

. Lets set it tosin

(u 

) + 1.Time arguments tell blocks ‘when’ to act during a simulation

Simulation in SimulinkBasics

Page 42: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 42/95

Block Manipulation

Blocks have many sorts of parameters

To set a block’s parameters, right-click on a block and select theparameters option

Our gaussian signal has mean and variance and seed parameters.Right click and set them to 0.5 and 1.5 respectively, be sure to noteor set seed in rng’s

The Matlab Function takes a function as a parameter with

vector-valued argumentu 

. Lets set it tosin

(u 

) + 1.Time arguments tell blocks ‘when’ to act during a simulation

The scope box

Simulation in Simulink

Basics

Page 43: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 43/95

A First Run

Simulation in Simulink

Basics

Page 44: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 44/95

A First Run

1 Open a useful monitor of the simulation by double clicking on

the scope box

Simulation in Simulink

Basics

Page 45: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 45/95

A First Run

1 Open a useful monitor of the simulation by double clicking on

the scope box2 Now lets run the simulation...

Simulation in Simulink

Basics

Page 46: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 46/95

A First Run

1 Open a useful monitor of the simulation by double clicking on

the scope box2 Now lets run the simulation...

3 First set the simulation parameters typing Ctrl + E

Simulation in Simulink

Basics

Page 47: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 47/95

A First Run

1 Open a useful monitor of the simulation by double clicking on

the scope box2 Now lets run the simulation...

3 First set the simulation parameters typing Ctrl + E

4 Many options; lets set the time from 0 to 25

Simulation in Simulink

Basics

Page 48: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 48/95

A First Run

1 Open a useful monitor of the simulation by double clicking on

the scope box2 Now lets run the simulation...

3 First set the simulation parameters typing Ctrl + E

4 Many options; lets set the time from 0 to 25

5 Now click on Simulation, Start

Simulation in Simulink

Basics

Page 49: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 49/95

Output to Matlab

Simulation in Simulink

Basics

Page 50: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 50/95

Output to Matlab

1 We often want the simulation data in Matlab

Simulation in Simulink

Basics

Page 51: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 51/95

Output to Matlab

1 We often want the simulation data in Matlab

2 Go to the library main, click on sinks

Simulation in Simulink

Basics

Page 52: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 52/95

Output to Matlab

1 We often want the simulation data in Matlab

2 Go to the library main, click on sinks

3 Drag simout into the model and connect before scope

Simulation in Simulink

Basics

Page 53: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 53/95

Output to Matlab

1 We often want the simulation data in Matlab

2 Go to the library main, click on sinks

3 Drag simout into the model and connect before scope

4 Right click and call the object output

Simulation in Simulink

Basics

Page 54: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 54/95

Output to Matlab

1 We often want the simulation data in Matlab

2 Go to the library main, click on sinks

3 Drag simout into the model and connect before scope

4 Right click and call the object output

5 Returns a matlab structure...run the sim and lets take a look

Simulation in Simulink

Basics

Page 55: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 55/95

Output More to Matlab

Simulation in Simulink

Basics

Page 56: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 56/95

Output More to Matlab

1 Suppose we want to get the signal at different points in thesimulation

Simulation in Simulink

Basics

Page 57: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 57/95

Output More to Matlab

1 Suppose we want to get the signal at different points in thesimulation

2 Drag another simout onto the screen

Simulation in Simulink

Basics

O M M

Page 58: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 58/95

Output More to Matlab

1 Suppose we want to get the signal at different points in thesimulation

2 Drag another simout onto the screen

3 Lets grab the original gaussian signal

Simulation in Simulink

Basics

O M M

Page 59: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 59/95

Output More to Matlab

1 Suppose we want to get the signal at different points in thesimulation

2 Drag another simout onto the screen

3 Lets grab the original gaussian signal

4 Name the second simout output

Simulation in Simulink

Basics

O M M

Page 60: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 60/95

Output More to Matlab

1 Suppose we want to get the signal at different points in thesimulation

2 Drag another simout onto the screen

3 Lets grab the original gaussian signal

4 Name the second simout output

5 Connect to the line between the signal and the function..run

the simulation

Simulation in Simulink

Basics

O F

Page 61: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 61/95

Output to File

Simulation in Simulink

Basics

Output to File

Page 62: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 62/95

Output to File

1 The best way to assure your simulated data is not lost is tosave it immediately

Simulation in Simulink

Basics

Output to File

Page 63: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 63/95

Output to File

1 The best way to assure your simulated data is not lost is tosave it immediately

2 Go into sinks again and select a untitled.mat file.

Simulation in Simulink

Basics

Output to File

Page 64: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 64/95

Output to File

1 The best way to assure your simulated data is not lost is tosave it immediately

2 Go into sinks again and select a untitled.mat file.

3 Right click to set file extension...will write to workingdirectory if no extension is provided

Simulation in Simulink

Basics

Output to File

Page 65: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 65/95

Output to File

1 The best way to assure your simulated data is not lost is tosave it immediately

2 Go into sinks again and select a untitled.mat file.

3 Right click to set file extension...will write to workingdirectory if no extension is provided

4 The signal can be saved in different times along the modelpath

Simulation in Simulink

Basics

Output to File

Page 66: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 66/95

Output to File

1 The best way to assure your simulated data is not lost is tosave it immediately

2 Go into sinks again and select a untitled.mat file.

3 Right click to set file extension...will write to workingdirectory if no extension is provided

4 The signal can be saved in different times along the modelpath

5 Somewhat inconvenient, every time you want a new positionon the path, you need a new file.

Simulation in Simulink

Basics

Using Data From Matlab Workspace I

Page 67: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 67/95

Using Data From Matlab Workspace I

There are many reasons we could want to use data from thematlab workspace

Simulation in Simulink

Basics

Using Data From Matlab Workspace I

Page 68: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 68/95

Using Data From Matlab Workspace I

There are many reasons we could want to use data from thematlab workspace

1

We may want to use data in memory rather than generate it

Simulation in Simulink

Basics

Using Data From Matlab Workspace I

Page 69: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 69/95

Using Data From Matlab Workspace I

There are many reasons we could want to use data from thematlab workspace

1

We may want to use data in memory rather than generate it2 It may be useful to use real-world data in the model.

Simulation in Simulink

Basics

Using Data From Matlab Workspace I

Page 70: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 70/95

Using Data From Matlab Workspace I

There are many reasons we could want to use data from thematlab workspace

1

We may want to use data in memory rather than generate it2 It may be useful to use real-world data in the model.

3 It may be difficult to use specific generators/rng streams inthe simulation

Simulation in Simulink

Basics

Using Data From Matlab Workspace I

Page 71: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 71/95

Using Data From Matlab Workspace I

There are many reasons we could want to use data from thematlab workspace

1

We may want to use data in memory rather than generate it2 It may be useful to use real-world data in the model.

3 It may be difficult to use specific generators/rng streams inthe simulation

4 We could use the inputs/outputs of previous simulations asinputs to the current simulation

Simulation in Simulink

Basics

Using Data From Matlab Workspace II

Page 72: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 72/95

Using Data From Matlab Workspace II

All of the objects in the workspace are available

Simulation in Simulink

Basics

Using Data From Matlab Workspace II

Page 73: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 73/95

All of the objects in the workspace are available

1 First, lets put something in the workspace, issue the commandx = [1:100; rand(1,100)]’

Simulation in Simulink

Basics

Using Data From Matlab Workspace II

Page 74: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 74/95

All of the objects in the workspace are available

1 First, lets put something in the workspace, issue the commandx = [1:100; rand(1,100)]’

2

Creates a 100x2 matrix with the first column indicating thetime stamp

Simulation in Simulink

Basics

Using Data From Matlab Workspace II

Page 75: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 75/95

All of the objects in the workspace are available

1 First, lets put something in the workspace, issue the commandx = [1:100; rand(1,100)]’

2

Creates a 100x2 matrix with the first column indicating thetime stamp

3 Right Click and delete the random generator

Page 76: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 76/95

Simulation in Simulink

Basics

Using Data From Matlab Workspace II

Page 77: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 77/95

All of the objects in the workspace are available

1 First, lets put something in the workspace, issue the commandx = [1:100; rand(1,100)]’

2

Creates a 100x2 matrix with the first column indicating thetime stamp

3 Right Click and delete the random generator

4 Now go to Sources and drag simin

5

Right click on simin and tell it to use x

Simulation in Simulink

Basics

Using Data From Matlab Workspace II

Page 78: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 78/95

All of the objects in the workspace are available

1 First, lets put something in the workspace, issue the commandx = [1:100; rand(1,100)]’

2

Creates a 100x2 matrix with the first column indicating thetime stamp

3 Right Click and delete the random generator

4 Now go to Sources and drag simin

5

Right click on simin and tell it to use x6 Now lets set the simulation time to 0-250 and run it

Simulation in Simulink

Basics

Using Data From Matlab Workspace II

Page 79: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 79/95

All of the objects in the workspace are available

1 First, lets put something in the workspace, issue the commandx = [1:100; rand(1,100)]’

2

Creates a 100x2 matrix with the first column indicating thetime stamp

3 Right Click and delete the random generator

4 Now go to Sources and drag simin

5

Right click on simin and tell it to use x6 Now lets set the simulation time to 0-250 and run it

7 Notice anything odd?...extrapolation

Simulation in Simulink

Basics

Scope Plot of Multiple Characteristics

Page 80: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 80/95

It is easy to visualize how things move together

Simulation in Simulink

Basics

Scope Plot of Multiple Characteristics

Page 81: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 81/95

It is easy to visualize how things move together

1 Go to search, enter mux

Simulation in Simulink

Basics

Scope Plot of Multiple Characteristics

Page 82: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 82/95

It is easy to visualize how things move together

1 Go to search, enter mux

2 This block concatenates multiple signals into larger

vector-valued signals

Simulation in Simulink

Basics

Scope Plot of Multiple Characteristics

Page 83: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 83/95

It is easy to visualize how things move together

1 Go to search, enter mux

2 This block concatenates multiple signals into larger

vector-valued signals3 Drag to the graphic

Simulation in Simulink

Basics

Scope Plot of Multiple Characteristics

Page 84: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 84/95

It is easy to visualize how things move together

1 Go to search, enter mux

2 This block concatenates multiple signals into larger

vector-valued signals3 Drag to the graphic

4 Connect the input and output to the two mux input wedges

Simulation in Simulink

Basics

Scope Plot of Multiple Characteristics

Page 85: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 85/95

It is easy to visualize how things move together

1 Go to search, enter mux

2 This block concatenates multiple signals into larger

vector-valued signals3 Drag to the graphic

4 Connect the input and output to the two mux input wedges

5 Run the simulation and observe

Simulation in Simulink

Basics

Scope Plot of Multiple Characteristics

Page 86: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 86/95

It is easy to visualize how things move together

1 Go to search, enter mux

2 This block concatenates multiple signals into larger

vector-valued signals3 Drag to the graphic

4 Connect the input and output to the two mux input wedges

5 Run the simulation and observe

6 Look at the Scope

Simulation in Simulink

Basics

Scope Plot of Multiple Characteristics

Page 87: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 87/95

It is easy to visualize how things move together

1 Go to search, enter mux

2 This block concatenates multiple signals into larger

vector-valued signals3 Drag to the graphic

4 Connect the input and output to the two mux input wedges

5 Run the simulation and observe

6 Look at the Scope7 Which is which? We need a legend.

Simulation in Simulink

Basics

An Alternative Multiple Characteristic Plot

Page 88: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 88/95

It is easy to visualize how things move together..again

Simulation in Simulink

Basics

An Alternative Multiple Characteristic Plot

Page 89: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 89/95

It is easy to visualize how things move together..again

1 Right click in model area and choose Signal & Scope manager

Simulation in Simulink

Basics

An Alternative Multiple Characteristic Plot

Page 90: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 90/95

It is easy to visualize how things move together..again

1 Right click in model area and choose Signal & Scope manager

2 Under viewers expand Simulink

Simulation in Simulink

Basics

An Alternative Multiple Characteristic Plot

Page 91: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 91/95

It is easy to visualize how things move together..again

1 Right click in model area and choose Signal & Scope manager

2 Under viewers expand Simulink

3

Double Click Scope

Simulation in Simulink

Basics

An Alternative Multiple Characteristic Plot

Page 92: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 92/95

It is easy to visualize how things move together..again

1 Right click in model area and choose Signal & Scope manager

2 Under viewers expand Simulink

3

Double Click Scope4 Right click on the scope and choose Edit Signal

Connections

Simulation in Simulink

Basics

An Alternative Multiple Characteristic Plot

Page 93: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 93/95

It is easy to visualize how things move together..again

1 Right click in model area and choose Signal & Scope manager

2 Under viewers expand Simulink

3

Double Click Scope4 Right click on the scope and choose Edit Signal

Connections

5 Select the inputs and outputs then close.

Simulation in Simulink

Basics

An Alternative Multiple Characteristic Plot

Page 94: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 94/95

It is easy to visualize how things move together..again

1 Right click in model area and choose Signal & Scope manager

2 Under viewers expand Simulink

3

Double Click Scope4 Right click on the scope and choose Edit Signal

Connections

5 Select the inputs and outputs then close.

6

Run the simulation and double click on the glasses

Simulation in Simulink

Basics

An Alternative Multiple Characteristic Plot

Page 95: Simulink Present

8/3/2019 Simulink Present

http://slidepdf.com/reader/full/simulink-present 95/95

It is easy to visualize how things move together..again

1 Right click in model area and choose Signal & Scope manager

2 Under viewers expand Simulink

3

Double Click Scope4 Right click on the scope and choose Edit Signal

Connections

5 Select the inputs and outputs then close.

6

Run the simulation and double click on the glasses7 Now right click on the plot space and select legend to get a

legend


Recommended