clear all;

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

[t,x,y] = sim('sigma_delta_L1_sim', T*(N-1));
Y = y(:, 3);
T = y(:, 1);

Y

[f, p, pi] = avg_spectrum(2*Y);
p = p * N/2;              % dBWN

figure(1);
plot(f, 10*log10(p));
xlabel('Frequency   [ f/f_s ]');
ylabel('Amplitude   [ dBWN ]');
axis([0 0.5 -50 30]);
title('First order sigma-delta, DC input');

figure(2);
L = 50;
stairs(Y(1:L));
xlabel('Time  [t/T]');
ylabel('Output');
axis([0 L -0.6 0.6]);
title('First order sigma-delta, DC input');
