Example H3.7

MATLAB code for example 3.7 from the book "Regeltechniek voor het HBO"

Bode diagram and Polar diagram of first order system

Copyright (c) 2021, Studieboeken Specialist Permission is granted to copy, modify and redistribute this file, provided that this header message is retained.
Table of Contents

The given situation

Assume that a first order system, type RC-network, is given as in figure 3.2 in the book:
Assume that K > 0 and that ω and τ are also > 0 . Thus the following equations are valid for the length and the angle of the vector :
and

Bode diagram

Before we draw the bodediagram using MATLAB commands we could already think about how it could look like. Let us first take the case where ω is very small and approaching zero. In that case: and . Then let's take the case where ω is very big. Then and
Another interesting case is the one where . This we call the breaking point. Here , that is why it is also called the -3dB point.
In order to draw a bode diagram in MATLAB we need to assign some numbers:
% clear all variables from Workspace and close all figures
clear variables;
close all;
% Define 's' variable
s=tf('s');
 
R =10000; % Ohm
C = 1e-6; % Farad
K = 1; % Gain of the RC network is one
 
Tau = R*C;
H = K / (s*Tau+1);
 
figure(101);
bode(H);
grid on;
% Fix the frequency range to make it easier to see the effect of
% a changing value for R
xlim([1 1e6]);

Nyquist diagram (polaire figuur)

figure(102);
nyquist(H);

Conclusions

We can see in both diagrams that the amplitude of the harmonic outputsignal gets smaller and the phase difference gets biggers as the frequency increases. A response like this is called a Low Pass Filter response.

Generate MATLAB figure(s) for usage in the book

Init create Enhanced Figures

Close all the earlier enhanced figures with a certain tag
EnhancedFig = findobj(0, 'Tag', 'EnhancedImage');
close(EnhancedFig);

Enhance the figures

figure1=figure(1001);
% Give it a tag
set(gcf, 'Tag','EnhancedImage');
% create the pzmap plot again but now with a figure handle
h = nyquistplot(H); % Use this command to return plot handle to programmatically customize the plot.
p = getoptions(h);
p.XLim = {[0, 1.5]};
p.YLim = {[-0.7, 0.5]};
p.ShowFullContour = 'off'; % Only show positive frequencies
p.Title.String = 'Nyquist Diagram for a first order system';
p.Xlabel.String = 'Re(H)';
p.Ylabel.String = 'Im(H)';
setoptions(h,p);
 
% Calculate location axis
Xoffset=0.14; % left part of the figure window not used by the graph
Scale=0.8; % part of the whole figure window used by the graph
Vaxis_loc=Xoffset+0.8*abs(1.5)/abs(0-1.5);
% Place labels
 
 
% Place textarrows
omega = char(969); % Greek letter omega
annotation(figure1,'textarrow','X',[0.468 0.401],'Y',[0.188 0.231],...
'String',[omega, ' = 1 /tau']);
annotation(figure1,'textarrow','X',[0.73 0.655],'Y',[0.53 0.56],'String',[omega, ' = 0']);
annotation(figure1,'textarrow','X',[0.24 0.15],'Y',[0.60 0.56],'String',[omega, ' = inf']);