# Help combine the two scripts

5 views (last 30 days)
ToasterPanda on 18 May 2014
Answered: Raghunandan V on 5 Oct 2018
Maybe someone can help connect these two scripts:
clear all;
x=[2 2 2 2 2 2 2 2 2 2]
autocorr(x);
N=length(x);
y=x;
z=x;
for i=1:N-1
for i=N-1:-1:1
x(i+1)=x(i);
end
x(1)=0;
z=[z; x];
end;
m=[z]*[y'];
m=m/N
stem(m);
title('auto-correlation');
xlabel('time index');
ylabel('amplitude');
and
clear all;
x=[2 2 2 2 2 2 2 2 2 2]
autocorr(x);
N=length(x);
y=x;
z=x;
for i=1:N-1
for i=N-1:-1:1
x(i+1)=x(i);
end
x(1)=0;
z=[z; x];
end;
m=[z]*[y'];
g=m/N
stem(g, g');
title('auto-correlation');
xlabel('time index');
per isakson on 18 May 2014
Edited: Image Analyst on 19 May 2014
The two scripts looks nearly identical to me. What do you mean by "connect" or "combine" ?

Raghunandan V on 5 Oct 2018
% clear all;
x=[2 2 2 2 2 2 2 2 2 2]
autocorr(x);
N=length(x);
y=x;
z=x;
for i=1:N-1
for i=N-1:-1:1
x(i+1)=x(i);
end
x(1)=0;
z=[z; x];
end;
m=[z]*[y'];
g=m/N
stem(g, g');
title('auto-correlation');
xlabel('time index');
m=m/N
stem(m);
title('auto-correlation');
xlabel('time index');
ylabel('amplitude');