I would like to have a code that can generate the maltiplication for x after shifting them many time
x=[1 2 4 1 3 4 5 1 3]
I would like to have a loop that can generate the autocorrlation for x with itself.
to illustrate;
x*x
R(1)=sum([1 2 4 1 3 4 5 1 3]*[1 2 4 1 3 4 5 1 3])/Length(x)
R(2)=sum([ 2 4 1 3 4 5 1 3]*[1 2 4 1 3 4 5 1 ])/Length(x-1)
and so forth until the R(N) computed

답변 (1개)

Catalytic
Catalytic 2019년 3월 29일
편집: Catalytic 2019년 3월 29일

1 개 추천

R = ifftshift(xcorr(x,'unbiased'))

댓글 수: 3

Matt J
Matt J 2019년 3월 29일
Or, if you don't have the Signal Processing ToolBox,
e=ones(size(x));
R=ifftshift( conv(x,flip(x))./conv(e,e) );
Willim
Willim 2019년 3월 30일
The results for the both codes you provide are not same
Catalytic
Catalytic 2019년 3월 30일
편집: Catalytic 2019년 3월 30일
The differences I see are super-small.
x=[1 2 4 1 3 4 5 1 3];
e=ones(size(x));
R1 = ifftshift(xcorr(x,'unbiased'));
R2=ifftshift( conv(x,flip(x))./conv(e,e) );
>> difference=max(abs((R1-R2)))
difference =
3.5527e-15

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2019년 3월 29일

편집:

2019년 3월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by