% PIDT
% Regelungstechnik
% M.Hess A. Jetzer 22.11.2000

clc;
clear;

%Definitionen
w=linspace(0.01,1000,1000);
Kp=0.25;
Tn=10;

%Regler1
Aw1=20.*log(Kp.*sqrt(1+(1./(Tn*w))));
Yw1=(atan(-1./(w.*Tn))./pi).*180;

%Regler2
Tv=0.1;
Aw2=20.*log(Kp.*sqrt(1+(Tv.*w-(1./(Tn.*w)))));
Yw2=(atan(Tv.*w-1./(Tn.*w))./pi).*180;

%Regler3
T=0.01;
Aw3=20.*log(Kp.*sqrt(((1+(Tv.*w.*w.*T)./(1+(w.*w.*T^2))).*((1+(Tv.*w.*w.*T)./(1+(w.*w.*T^2))))+((((Tv.*w)./(1+(w.*w.*T^2)))-(1./(Tn.*w))).*(((Tv.*w)./(1+(w.*w.*T^2)))-(1./(Tn.*w)))))));
Yw3=(atan((((Tv.*w)./(1+w.*w.*T^2))-(1./(Tn.*w)))./(1+((Tv.*w.*w.*T)./(1+(w.*w.*T^2)))))./pi).*180;


%Plot
figure('Name','Bodediagramme','NumberTitle','off');% Festlegen der Grafik
clf;
hold; 
subplot(2,1,1);
semilogx(w,Aw1,'-r',w,Aw2,'--b',w,Aw3,':g');
axis([0.01 1000 -40 40]);
title('Amplitudengang');
xlabel('Omega');
ylabel('A(w)');
legend('Regler 1','Regler 2','Regler 3');
grid;
subplot(2,1,2);
semilogx(w,Yw1,'-r',w,Yw2,'--b',w,Yw3,':g');
axis([0.01 1000 -90 90]);
title('Phasengang');
xlabel('Omega');
ylabel('Phi(w)');
legend('Regler 1','Regler 2','Regler 3');
grid;