Tutorial 3 - 1
The University of New BrunswickDepartment of Electrical and Computer Engineering
Fredericton, NB, E3B 5A3 Canada
Tutorial 3 - 2
Using Matlab/Simulink Using Matlab/Simulink
Tutorial 3 - 3
Matlab Main Window
Command window
Directory listing
Tutorial 3 - 4
Matlab Main Window
Type simulink on command window andhit <enter>
Or double click the file to open
Tutorial 3 - 5
Simulink Library Browser
Select NEW to start a new
project
Tutorial 3 - 6
Starting a new project
Drag and drop
Tutorial 3 - 7
Connecting Blocks
Select the firstblock, hold <Ctrl> key down andclick the targetblock. This goeswith single inputblocks. Or thefirst input of theblocks withmultiple inputs.
Hold left mouse button on the connection point of one of the blocks anddrag it to the connection point of the other block then relase the mouse
Tutorial 3 - 8
Changing Block Parameters
Double click the blocks to edit their parameters.
Tutorial 3 - 9
Changing Block Parameters
Move mouse over a block and hold theright button down to get more featuresfor the block.
Tutorial 3 - 10
Displaying and Printing Graphs
You can display the responses using scope window. However, scopewindow is not good to be used in reports. However, you cannot edit the axis labels. Besides, the dark background is not good for printing.
Tutorial 3 - 11
Exporting Data to .MAT file
From the Simulink Library Sinks, select theblock To File
Drag the block To Fileon to your work project
You can export your data toMatlab workspace or to an .m file and then plot it for thereports.
Tutorial 3 - 12
Exporting Data to .MAT file
Double click each To File block andchange file name and variable name tosuit your model system.
Tutorial 3 - 13
Exporting Data to .MAT file
This is the file (p1.mat), which contains theexported data.
The first row of the exporteddata is the simulation time in seconds and the second rowis the variable.
The variable stored here is PP1.
The file p1.mat is saved into your working directory. This file is then called from either Matlab Command Window or from an .m file.
Tutorial 3 - 14
Using .MAT files in MATLAB
Load .mat file content to workspace
Shows the variables currently in memory
The variable in memory is PP1
Get transpose of PP1 as D so that you willhave 2 columns data file instead of 2 rows
Get time t and variable y1 as 2 separatesingle column vectors for plotting.
Plot y vs. t.
Tutorial 3 - 15
Using .MAT files in MATLAB
Copy figure to clipboard. Then fromclipboard to your document as on the left..
Tutorial 3 - 16
Using .MAT files in MATLAB
This is a sample for a good grapgh in a document file.
Tutorial 3 - 17
Using .MAT files in .m files
You can download this.m file from thecourse site.
Tutorial 3 - 18
Printer Friendly Plots
Save ink or toner.