N  = 2^10;              % simulation length (output samples)
A  = 0;                 % signal amplitude
offset = 1/11;
fs = 1;                 % sampling frequency 
T  = 1/fs;              % time step
fx = 0;                 % signal frequency (dc)

[t,x,y] = sim('L19_level1_sim', T*(N-1));

X = y(:,1);
Q = y(:,2);
Y = y(:,3);
w = nuttallwin(length(Y));

s = abs(fft(Y .* w)) / sqrt(N);
s = s(1:N/2);
f = (0:length(s)-1) / N;

plot(f, 20*log10(s));
xlabel('Frequency   [ f/f_s ]');
ylabel('Amplitude   [ dBWN ]');
axis([min(f) max(f) -80 20]);
fixfig;

figure(2);
n = 55;
stairs(t(1:n)/11-0.15, Y(1:n));
axis([0 4.5 -1.1 1.1]);
xlabel('Time  [t/11]');
ylabel('Amplitude');
fixfig;
