How can I study Autocorrelation function of common inputs?

조회 수: 4 (최근 30일)
Teodoro Coluccio
Teodoro Coluccio 2022년 6월 28일
답변: Balaji Udayagiri 2022년 7월 5일
I'm trying to study the autocorrelation function for some basic signals, such as rectangularPulse and triangularPulse, and to do that I found the xcorr () function. The problem is that the function wants 2 vectors in input, so I'm trying to convert the function to vectors, but mine can be a non linear function...
Also I don't even know if this is the right way...
Everything I'm trying I found here https://en.mathworks.com/help/signal/correlation-and-convolution.html.

채택된 답변

Balaji Udayagiri
Balaji Udayagiri 2022년 7월 5일
Hi Teodoro,
As per my understanding, you want to know how to perform autocorrelation for non-linear functions.
You can use the xcorr() function to do the same.
Here is an example code using a sine function to do the same:
fs = 1.0e4;
t = 0:1/fs:0.005;
signal = sin(2*pi*1000*t)';
figure(1);
stem(t,signal);
[c,lags] = xcorr(signal);
figure(2);
stem(lags,c)
You can replace the sin function of any linear or non-linear function of your choice.

추가 답변 (1개)

Jonas
Jonas 2022년 6월 30일
편집: Jonas 2022년 6월 30일
you can simply generate your own vectors in matlab and do some studying
e.g.
rectPulse = [zeros(1,10) ones(1,15) zeros(1,10)];
tiledlayout('flow');
nexttile()
stem(rectPulse);
nexttile()
[val,lag]=xcorr(rectPulse);
stem(lag,val);
linkaxes()
figure
triPulse=zeros(1,100);
triPulse(31:70)=(1:40)/10;
tiledlayout('flow');
nexttile()
plot(triPulse);
nexttile()
[val,lag]=xcorr(triPulse);
plot(lag,val);
nexttile()
val=conv(triPulse,triPulse);
plot(val);

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by