% define systems individually and then combine via 
% multiplications (probably should use state space for higher 
% accuracy in real computations
% D L Trumper 11/8/04

sys1 = tf(5,[1 0]);
sys2 = tf([0.5 1],[0.1 1]);
sys3 = tf([1/20^2 0.1/20 1],[1/100^2 0.2/100 1]); 
sys4 = tf([1],[1/1000^2 0.02/1000 1]);

ww = logspace(0,4,2000);
totalsys = sys1*sys2*sys3*sys4;

[mag,phase] = bode(totalsys,ww);
mag2 = mag(:);
phase2 = phase(:);

figure(1); clf
subplot(2,1,1)
loglog(ww,mag2)
axis([1e0 1e4 1e-2 1e2])
grid on

subplot(2,1,2)
semilogx(ww,phase2)
axis([1e0 1e4 -300 100])
set(gca,'YTick',[-360:90:360])
grid on

