Example H3.2

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

Determine the stepresponse in s-domain from a given pz-map

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

a) Determine response in s-domain

Determine the response in the s-domain from pz-map given in figure below:
This could be the result of where the system H1 and the input X1 are equal to:

Visualize the steps above: response of proces H1 to input:

Calculate and show the poles of
% clear all variables from Workspace and close all figures
clear variables;
close all;
% Define 's' variable
s=tf('s');
 
H1=5*(s+2)/((s+3)*(s+5));
X1=2/s^2;
Y1=X1*H1;
zpk(Y1)
ans = 10 (s+2) --------------- s^2 (s+5) (s+3) Continuous-time zero/pole/gain model.
figure(101);
pzmap(Y1);
Define input parameters to show response to an x1=2*t input:
Tsim1=1; % Simulation time in seconds
figure(102);
t1 = 0:Tsim1/100:Tsim1;
x1 = 2*t1;
% Simulate the response of system H1 to the input x1
lsimplot(H1,x1,t1);
grid on;
title('Response to an input 2*t');

b) Determine response in s-domain

Determine the response in the s-domain from pz-map given in figure below:
This could be the result of where the system H2 and the input X2 are equal to:

Visualize the steps above: response of proces H2 to input:

Calculate and show the poles of
H2=3*(s+6)/((s+1)*(s+4));
X2=5*s/(s^2+9);
Y2=X2*H2;
zpk(Y2)
ans = 15 s (s+6) --------------------- (s+4) (s+1) (s^2 + 9) Continuous-time zero/pole/gain model.
figure(103);
pzmap(Y2);
Define input parameters to show response to an x2=5*cos(3t) input:
Tsim2=7; % Simulation time in seconds
figure(104);
t2 = 0:Tsim2/100:Tsim2;
x2 = 5*cos(3*t2);
% Simulate the response of system H2 to the input x2
lsimplot(H2,x2,t2);
grid on;
title('Response to an input 5*cos(3*t)');

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=pzplot(X1*H1);
grid on;
% get the handle to the plot options
p=getoptions(h);
% Adjust Title
p.Title.String='PN beeld van \itY_1(s)';
p.XLim=[-6 1];
p.YLim=[-2 2];
% write the options to the figure
setoptions(h,p);
 
figure(1002);
% Give it a tag
set(gcf, 'Tag','EnhancedImage');
% create the timeresponse plot again but now with a figure handle
h=lsimplot(H1,x1,t1);
grid on;
% get the handle to the plot options
p=getoptions(h);
% Adjust Title
p.Title.String='Slope response \ity_1(t)';
% Make input invisible. If this does not work
% create the figure again with this code in an m-
% script and toggle with a right mouse click in
% the figure the input signal
p.InputVisible={'off'};
p.XLim=[0 Tsim1];
p.YLim=[0 2];
% write the options to the figure
setoptions(h,p);
 
figure(1003);
% Give it a tag
set(gcf, 'Tag','EnhancedImage');
% create the pzmap plot again but now with a figure handle
h=pzplot(X2*H2);
grid on;
% get the handle to the plot options
p=getoptions(h);
% Adjust Title
p.Title.String='PN beeld van \itY_2(s)';
p.XLim=[-6 1];
p.YLim=[-2 2];
% write the options to the figure
setoptions(h,p);
 
figure(1004);
% Give it a tag
set(gcf, 'Tag','EnhancedImage');
% create the timeresponse plot again but now with a figure handle
h=lsimplot(H2,x2,t2);
grid on;
% get the handle to the plot options
p=getoptions(h);
% Adjust Title
p.Title.String='Sine response \ity_2(t)';
% Make input invisible. If this does not work
% create the figure again with this code in an m-
% script and toggle with a right mouse click in
% the figure the input signal
p.InputVisible={'off'};
p.XLim=[0 Tsim2];
p.YLim=[-7 7];
% write the options to the figure
setoptions(h,p);