Commit 836ddc5c authored by Adwait Datar's avatar Adwait Datar
Browse files

Gitlab Runner Update from orc-aux-files/master:Add code for for 16_3, 17_1, 17_2

parent 3e76caa6
% ORC 16.3 :: Waterbed effect
%
% TUHH :: Institut for Control Systems :: Optimal and Robust Control
% Last update: 30.06.2020
% The following example is borrowed from:
% Skogestad, S. & Postlethwaite, I.
% "Multivariable Feedback Control - Analysis and Design"
% John Wiley & Sons, Ltd. , 2001
clear
clc
close all
%% Sub-problem a) and b)
% G = tf( 2, [1 1 0] );
% K1 = 0.1; K2 = 1; K3 = 10;
%% Sub-problem c)
G = tf( [-1 2],[1 2 0] );
K1 = 0.1; K2 = 0.5; K3 = 1.5;
%% Open loop transfer function L
L1 = G*K1; L2 = G*K2; L3 = G*K3;
figure()
margin(L1)
hold on
margin(L2)
margin(L3)
legend(['K1=' num2str(K1)], ['K2=' num2str(K2)], ['K3=' num2str(K3)])
figure()
nyquist(L1,'r')
hold on
nyquist(L2,'g')
nyquist(L3,'b')
legend(['K1=' num2str(K1)], ['K2=' num2str(K2)], ['K3=' num2str(K3)])
%% Frequency response Analysis: loop transfer functions
S1 = feedback( 1, L1 ); T1 = feedback( L1, 1 );
S2 = feedback( 1, L2 ); T2 = feedback( L2, 1 );
S3 = feedback( 1, L3 ); T3 = feedback( L3, 1 );
% Plot sensitivity and complementary sensitivity for different designs
figure()
subplot(211)
sigma( S1,'r-', S2,'g-', S3,'b-'); title('S');
subplot(212)
sigma( T1,'r-', T2,'g-', T3,'b-'); title('T')
legend(['K1=' num2str(K1)], ['K2=' num2str(K2)], ['K3=' num2str(K3)])
figure()
sigma(S1,'r-', S2,'g-', S3,'b-',T1,'r-', T2,'g-', T3,'b-');
title('S&T in one plot')
%% Time domain analysis
% Step response of the closed loop (Without input disturbance)
figure()
step(T1,'r-',T2,'g-',T3,'b-');
legend(['K1=' num2str(K1)], ['K2=' num2str(K2)], ['K3=' num2str(K3)])
%% Sine tracking of the closed loop without input disturbance
t=0:0.1:100; % time
u=sin(0.05*t); % Step input
figure()
lsim(T1,u',t,'r')
hold on
lsim(T2,u',t,'g')
lsim(T3,u',t,'b')
legend(['K1=' num2str(K1)], ['K2=' num2str(K2)], ['K3=' num2str(K3)])
%%
% Sine tracking of the closed loop with input disturbance
t=0:0.1:100; % time
u=sin(0.05*t); % Step input
d=0.05*sin(1.9*t); % Input disturbance
ud=(u+d)'; % input=step+noise
figure()
lsim(T1,ud,t,'r')
hold on
lsim(T2,ud,t,'g')
lsim(T3,ud,t,'b')
legend(['K1=' num2str(K1)], ['K2=' num2str(K2)], ['K3=' num2str(K3)])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment