%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%Octave:
%Simulation and poles and zeros of transfer functions
%
%Finn Aakre Haugen
%University of South-Eastern Norway
%finn.haugen@usn.no
%24 Oct 2018
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
close all
format compact
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Definition of s as a symbol of the Laplace variable:

s = tf('s')

%Example of creating a transfer function of name H1:

K = 1
T = 1
H1 = K/(T*s+1)

%-------------------------------------------------------
%Simulation of the step response of H1:

figure(1)
step(H1)
title('Step response of H1(s)')
xlabel('t [s]')
grid minor on

%-------------------------------------------------------
%Simulation of the impulse response of H1:

figure(2)
impulse(H1)
title('Impulse response of H1(s)')
xlabel('t [s]')
grid minor on

%-------------------------------------------------------
%Calculation of the poles (p) and the zeros (z) of H1
%(however, in this example the transfer function has no zeros):

figure(3)
[p,z] = pzmap(H1)%Calculation of p og z:
pzmap(H1);%Plotting p (og z, if any)
ylabel('Im')
xlabel('Real')
grid minor on
