% Fig. 6.12   Feedback Control of Dynamic Systems, 8e 
%             Franklin, Powell, Emami
%

clear all;
%close all;
clf

num1 = [10 10];
den1 = [1 10];

num2 = [10 -10]; % positive zero 
den2 = den1;

w=logspace(-2,3,100);

[m1,p1] = bode( num1, den1, w );

[m2,p2] = bode( num2, den2, w );

figure(1)

subplot(2,1,1)
loglog(w,m1,'b-','LineWidth',2);

grid on;
xlabel('\omega (rad/sec)');
ylabel('Magnitude');

title('Bode Plot of 10(s+1)/(s+10)');

subplot(2,1,2)
semilogx(w,p1,'b-','LineWidth',2);

axis( [ 0.01, 1000, 0, 200 ])
grid on;
xlabel('\omega (rad/sec)');
ylabel('Phase (deg)');



%pause;
figure(2)

subplot(2,1,1)
loglog(w,m2,'r--','LineWidth',2 );

grid on;
xlabel('\omega (rad/sec)');
ylabel('Magnitude');

title('Bode Plot of 10(s-1)/(s+10)');

subplot(2,1,2)
semilogx(w, p2, 'r--','LineWidth', 2);

axis( [ 0.01, 1000, 0, 200 ])

grid on;
xlabel('\omega (rad/sec)');
ylabel('Phase (deg)');



figure(3)

subplot(2,1,1)
loglog(w, m1, 'b-','LineWidth',2);
hold on;
loglog(w, m2, 'r--','LineWidth',2);

grid on;
xlabel('\omega (rad/sec)');
ylabel('Magnitude');

title('Bode Plot of 10(s+1)/(s+10) and 10(s-1)/(s+10)');


subplot(2,1,2)
semilogx(w, p1, 'b-', 'LineWidth',2);
hold on;
semilogx(w, p2, 'r--','LineWidth',2);

axis( [ 0.01, 1000, 0, 200 ])

grid on;
xlabel('\omega (rad/sec)');
ylabel('Phase (deg)');





%title('Bode Plot for a NMP System (b) phase');