Simulink/Matlab Help
This page contains some tips for using simulink. If you are
completely new to matlab, you should first learn some basic Matlab commands.
Henceforth, familiarity with Matlab will be assumed. Simulation
exercises will extensively use Simulink (a matlab package), and
familiarity with Simulink is not assumed.
List of Topics
Downloadable Documents
Basics:
- After the Simulink and ece359lib libraries are open,
open a new model through the file menu-option.
- To get a particular block inside the new model, just click and
drag it from the block library.
- To connect blocks, click on the starting point of the connection,
and drag the line that appears to the end point. To produce branching,
Conrol-click on a point on the connection, and drag to the end point.
- To set the parameters of a particular block (eg. frequency of a
sine wave generator), double click on it after you have copied it into
your model. You can use variable names that have been set in the
matlab workspace.
- You can also save the model in a model.mdl file. Use
the file menu to do this.
Notation:
- Commands in typewriter font -- help simulink
- Simulink library names in italics --
Simulink/Linear refers to the main Simulink family of blocks
and within it, the Linear blocks
- Notes of caution and crucial hints will be in bold -- Do not take this course
lightly !
Printing:
- To print models, use print from the file menu on the model window. This will
open a dialog box similar to the one for printing out plots. Try to
give more meaningful names to the blocks. Click on the block name to
change it.
- The fourier transformer output can be printed just like an
ordinary matlab plot. You may label the plots with hand. To change the
title of the plot, just change the name of the fourier transform
block. (This feature seems to be giving some trouble, please label
your graphs with a pencil if this does not work - Thanks)
- Instructions on printing out the scope output will be posted later
(you do not need it for the first experiment)
Scope
- The scope (from simulink/sinks) can be used to look
at the signal in time domain. Though it can be used while the
simulation is running, doing so can reduce the speed of simulation
slightly. Notice that the zoom in and zoom out features of scope are
a bit tricky. See documentation in Matlab.
- To take printouts of the scope data you need to
store the variables to the workspace. Click the upper right icon on
the scope menu. This will open a settings window. Select save to
workspace and give the variable name, say m. Then to plot
the variable m, use the command
plot(m(:,1),m(:,2)).
To look at the time structure of this signal more closely, use
plot(m(100:200,1),m(100:200,2)).
- To make the onscreen scope display more interesting, try to make the
window long. Set the time range of the scope to T_SIM and
click on the binocular icon to make the display fit into the
frame.
- Looking at both the input and output signals on the scope while
the simulation is running gives a good idea of the delay associated
with the system
- For getting two or more signals on the same plot,
save both variables to workspace and then plot them using the matlab
plot command.
Lots of Blocks
- Begin your diagram from the lower left of the window. Leaving a
wide left margin is also desirable. Reember that you can always expend
the bottom and right margins of the figure later, but not the left and
top margins.
- When drawing wires that criss cross a lot, try to leave the mouse
click while dragging the wire. See what effect this has, it may be
helpful if things seem to get cluttered.
- If a connection is left unattached, Matlab gives a warning
message on the workspace.
- Keep the wires as small as possible. If your setup is getting too
cluttered it is better to start afresh, rather than trying to run
wires all over the place.
Addition block (Avoid using multipliers)
- The addition block can be configured to add or subtract two signals. Double click on the block to change the signs.
Sine and Cosine
- The sine generator produces a sine wave by default. To change to
a cosine wave give a phase offset of pi/2.
Cut and Paste
- Left-click and drag can be used to select rectangles in any
Simulilnk window. the entire structure inside this rectangle is
selected.
- You can copy this rectangle to a buffer using ^c (or from
menu>Edit>Copy).
- To get the same rectangle in a different model, use ^v (or
menu>Edit>Paste).
ECE 359 home