Control Tutorials For MATLAB and Simulink - Extras - MATLAB Tips & Tricks
Control Tutorials For MATLAB and Simulink - Extras - MATLAB Tips & Tricks
SYSTEM
with them, most tasks are for the most part straightforward and intuitive.
CONTROL
Recent versions of the software provide many usesful toolboxes and GUI
PID interfaces to simplify your work. However, there are still a few things that
can be tricky to accomplish. This page provides a list of helpful tips and
ROOT LOCUS
tricks that should come in handly as you work through these control tutorials
FREQUENCY and elsewhere.
STATE-SPACE
Contents
DIGITAL
CONTROL
Changing the Frequency Units on the Bode Plots
To change between Hertz (Hz) and radians per second (rad/s) on the bode
plot, use the following commands:
s = tf('s');
G = 1/(s+1);
options = bodeoptions;
figure(1)
bode(G,options);
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Tips 1/4
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: MATLAB Tips & Tricks
Please refer to the Matlab help page on bodeoptions for more details and
optional parameters.
The Bode plot of a system, , shows the magnitude, (in dB), and
win = logspace(-2,2,5)
[mag,phase,wout] = bode(G,win);
size(wout)
size(mag)
size(phase)
win =
ans =
5 1
ans =
1 1 5
ans =
1 1 5
where win is the input frequency vector in rad/s, mag is the magnitude in
absolute units (i.e. not in dB), phase is the phase in degrees, and wout is
the output frequencies at which the response was evaulated, useful for
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Tips 2/4
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: MATLAB Tips & Tricks
magnitude and phase are actually (1 x 1 x n). This is because the bode
element of magnitude and phase corresponds to the jth input and ith output.
For the SISO systems we most often encounter, i = j =1, these singleton
mag = squeeze(mag)
phase = squeeze(phase)
mag =
1.0000
0.9950
0.7071
0.0995
0.0100
phase =
-0.5729
-5.7106
-45.0000
-84.2894
-89.4271
MATLAB is a wonderful tool for visualizing data and generating figures for
To change the font size of all text in a figure (titles, axis labels, legends,
etc.) we need to search for all axes and text objects using findall and
change their properties using set. This is the easiest way since figures may
containt multiple axes, e.g. bode, each with their own font size properties
and furthermore MATLAB handles titles and axes labels separately from tick
marks. Changing line width is treated in a similar fashion, and other
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Tips 3/4
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: MATLAB Tips & Tricks
figure(2)
bode(G)
% Set axes tick label font size, color, and line width
set(findall(gcf,'Type','axes'),'FontSize',11,'LineWidth',2,'XColor'
Please refer to the following pages to see all properties that can be modified
for figures and axes.
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Tips 4/4