% Simulated system:
m0=poly2th([1 -1.5 0.7],[1 0.5]);
randn('seed',26)
u=randn(200,1);
y=idsim(u,m0);
yn=y(101:200,1);
ym=idsim([zeros(7,1);sqrt(40);zeros(53,1);-sqrt(24);zeros(38,1)],m0);

figure(1)
% Figure 2.5
plot(yn)
axis([0 100 -15 15]) 
set(gca,'xtick',[0 50],'xticklabel',[0 50])
set(gca,'ytick',[-10 0 10])
set(gca,'yticklabel',[-10 0 10])
 
figure(2)
% Figure 2.6
plot(ym)
axis([0 100 -15 15])
set(gca,'xtick',[0 50],'xticklabel',[0 50])
set(gca,'ytick',[-10 0 10])
set(gca,'yticklabel',[-10 0 10])
 
% Time series model:
m00=poly2th([1 -1.5 0.7],[],[1 0.5]);
g00=th2ff(m00);[om,g00a]=getff(g00);
figure(3)
% Figure 2.7: (could also use bodeplot(g00))
loglog(om,g00a)
axis([0.04 4 0.1 1000])
set(gca,'ytick',[1 10 100])
set(gca,'yticklabel',[1 10 100])
set(gca,'xtick',[0.1 1]),set(gca,'xticklabel',[0.1 1])
title('\Phi_v(\omega)')

figure(4)
Y=fft(yn);
P=abs(Y).^2;P=P(1:50)/100;
om1=[0:49]*pi/50;
% Figure 2.8: (Could also use bodeplot(etfe(yn)))
loglog(om1,P)
title('|V_N(\omega)|^2')
axis([0.04 4 0.1 1000])
set(gca,'ytick',[1 10 100])
set(gca,'yticklabel',[1 10 100])
set(gca,'xtick',[0.1 1]),set(gca,'xticklabel',[0.1 1])
 