imp=[1; zeros(200,1)];
out=afilter(imp,-20);

m=mls(8);
d=xcorr(m, m);
plot(d);

d=xcorr([m;m;m], m)./length(m);
figure
plot(d);

figure;
stem(d(4*length(m):5*length(m)-1));

y=afilter([m; m; m]);
figure
stem([m; m; m]); hold on;
stem(y,'r');

hr=xcorr(y, m)./length(m); % raw IR
figure
stem(hr);
hr=hr((4*length(m):5*length(m)-1));
figure
plot(hr);

    % system: lin, noise
yn=afilter([m; m; m],-20);
figure
hn=xcorr(yn, m)./length(m); % raw IR
hn=hn((4*length(m):5*length(m)-1));
figure
plot(etc(hn)); title('noisy measurement with MLS');
figure;
plot(etc(out)); title('noisy measurement with impulse');


    % system: nonlin, lin
mnl=m+0.5*m.^3;
ynl=afilter([mnl; mnl; mnl]);

    % system: lin, nonlin
ynl=afilter([m;m;m],[],-20);

hnl=xcorr(ynl, m)./length(m);  % non lin IR
hnl=hnl(4*length(m):5*length(m)-1);
figure
hold on;
plot(etc(hnl),'r');
plot(etc(hr));
figure
spect(fft(hnl),44100,'r'); 
hold on;
spect(fft(hr),44100);