fs = 1000;
t = 0:0.1/fs:10;
t = t(1:10000);
randomSIGNAL = randn(1,10000);
figure;
plot(t,randomSIGNAL)
axis tight;
title('randomSIGNAL(signale tasadofi ya noise)')
xlabel('time_10seconds')
ylabel('amp')
%%%%%%%%%%%%%%%%%%%%%%%%%FILTER_KARDAN%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
n = 20;     %%%%%%%MARTABE0 FILTER%%%%%%%%%%%%%%
a = (1/n)*ones(1,n);   %%%%%%%%%%SOORATE  FILTER%%%%%%%%
b = 1; %%%%%%%%%%%%%%%%%%%%%%%%%%MAKHRAJ FILTER%%%%%%%%%
[h,f]=freqz(a,b,500,fs);
figure;
plot(f,20*log10(abs(h)),'g')
grid on
filtered = filtfilt(a,b,randomSIGNAL);
figure
plot(t,randomSIGNAL,'g',t,filtered,'r')
title('MOVING  AVERAGE')
xlabel('time( seconds)')
ylabel('amlitude')
Correlation2 = xcorr(randomSIGNAL,'unbiased');
figure
delays=[-length(randomSIGNAL)+1+9500:0 1:length(randomSIGNAL)];
plot(delays,'r')