Multiply and shift ?

1 Ansicht (letzte 30 Tage)
Willim
Willim am 29 Mär. 2019
Bearbeitet: Catalytic am 30 Mär. 2019
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

Antworten (1)

Catalytic
Catalytic am 29 Mär. 2019
Bearbeitet: Catalytic am 29 Mär. 2019
R = ifftshift(xcorr(x,'unbiased'))
  3 Kommentare
Willim
Willim am 30 Mär. 2019
The results for the both codes you provide are not same
Catalytic
Catalytic am 30 Mär. 2019
Bearbeitet: Catalytic am 30 Mär. 2019
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by