Professional Documents
Culture Documents
FL M Ali 195123 Quiz 1 LMV
FL M Ali 195123 Quiz 1 LMV
LMVFC SYSTEMS
2. is evaluated as 2.2618
8.
MATLAB CODE
%% Part 1 using wp
clc
clear all
close all
s=tf('s'); % Laplace transform variable 's'
G=tf(4,[0.0004 0.0396 0.96 -1]); % Plant to be controlled
wb=10; % desired closed-loop bandwidth
A=1/10000; % desired disturbance attenuation inside
bandwidth
M=1.5 ; % desired bound on hinfnorm(S) &
hinfnorm(T)
Wp=(s/M+wb)/(s+wb*A);
Wu=1 % Empty control weight
systemnames = 'G Wu Wp'; % Plant & weight definition
inputvar = '[ r(1);u(1)]'; % Inputs
outputvar = '[Wu;Wp;r-G]'; % Outputs
input_to_G = '[u]';
input_to_Wu = '[u]';
input_to_Wp = '[r-G]';
sysoutname = 'P'; % Generalized Plant
cleanupsysic = 'yes';
P=sysic % Finding P
[Kinf,ginf,gopt] = mixsyn(G,Wp,Wu,[]);
Gamma_min=gopt; %Gamma minimum for H-inf
controller
s=tf('s');
K=tf(Kinf); % Controller transfer function
L=(G*K); % Open loop system
S=1/(1+G*K); % Sensitivity
T=G*K/(1+G*K); % Complimentary sensitivity
Ms=getPeakGain(S) %Ms
Mt=getPeakGain(T) %Mt
[Gm,Pm,Wgm,Wc]=margin(L) % Wc gives crossover frequency
of open loop system
figure('Name','Bode Diag of Closed Loop System');
margin(T) % Closed loop response, Wc, GM and PM
figure
margin(K) % Frequency response of H inf controller
K_c=1.25;
tau=1.5;
K_s=K_c*(1+1/tau*s);
figure
margin(K_s) % Frequency response of PI controller
step(T) % Step response of closed loop system
%% Part 2 using wp2
clc
clear all
close all
s=tf('s'); % Laplace transform variable 's'
G=tf(4,[0.0004 0.0396 0.96 -1]); % Plant to be controlled
wb=10; % desired closed-loop bandwidth
A=1/10000; % desired disturbance attenuation inside
bandwidth
sA=sqrt(A);
M=1.5 ; % desired bound on hinfnorm(S) &
hinfnorm(T)
sM=sqrt(M);
Wp1=(s/sM+wb)/(s+wb*sA);
Wp2=Wp1*Wp1;
Wu=1 % Empty control weight
systemnames = 'G Wu Wp2'; % Plant & weight definition
inputvar = '[ r(1);u(1)]'; % Inputs
outputvar = '[Wu;Wp2;r-G]'; % Outputs
input_to_G = '[u]';
input_to_Wu = '[u]';
input_to_Wp2 = '[r-G]';
sysoutname = 'P'; % Generalized Plant
cleanupsysic = 'yes';
P=sysic % Finding P
[Kinf,ginf,gopt] = mixsyn(G,Wp2,Wu,[]);
Gamma_min=gopt; %Gamma minimum for H-inf
controller
s=tf('s');
K=tf(Kinf); % Controller transfer function
L=(G*K); % Open loop system
S=1/(1+G*K); % Sensitivity
T=G*K/(1+G*K); % Complimentary sensitivity
Ms=getPeakGain(S) %Ms
Mt=getPeakGain(T) %Mt
[Gm,Pm,Wgm,Wc]=margin(L) % Wc gives crossover frequency
of open loop system
figure('Name','Bode Diag of Closed Loop System');
margin(T) % Closed loop response, Wc, GM and PM
figure
margin(K) % Frequency response of H inf controller
K_c=1.25;
tau=1.5;
K_s=K_c*(1+1/tau*s);
figure
margin(K_s) % Frequency response of PI controller
step(T) % Step response of closed loop system