# autocorrelation of a signal after transforming the x-axis

4 Ansichten (letzte 30 Tage)
Sayanta Goswami am 9 Jan. 2024
Beantwortet: William Rose am 9 Jan. 2024
I have a signal, say y as a function of t. I have another parameter f. now I want to plot y as a function of (f*t) which is straight forward and I have done it. now I want to find the auto correlation of the singal say x as a function of ft. Basically need to change x-axis while doing the auto correlation. in other words, is there any option in matlab function xcorr where I can give the value of x-axis as an input? I would be greatful if someone can help me with that.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

William Rose am 9 Jan. 2024
There is not an option with xcorr() to apply a different time scale. The discrete cross- and auto-correlations are defined on a sample-by-sample basis. Therefore, if you want to know the autocorrelation with respect to a different time base, then the most direct way is to resample the signal on the new timebase. In your case, the new time base (ft) is gradually getting faster than the original time base. Therefore a signal that is a regular sinusoid on the original time base will look like a backwards chirp on the new time base: see example below.
y0=sin(4*pi*t);
figure; subplot(211), plot(t,y0,'-r'); xlabel('t'); grid on
subplot(212), plot(ft,y0,'-b'); xlabel('ft'); grid on
Load y. Compute and plot its autocorrelation:
[r1,lags1]=xcorr(y,y,'unbiased');
figure; plot(lags1,r1,'-r.');
xlabel('Lags 1'); title('Autocorr(y(t))'); grid on
Create a a constant-interval time base, t2, that spans the same time range as ft:
dt1=(t(end)-t(1))/(length(t)-1); % sampling rate for t
t2=ft(1):dt1:ft(end);
Resample y at the times t2:
y2=interp1(ft,y,t2);
Plot y versus ft, and y2 versus t2. They should look the same, except for the timing of the samples.
figure; plot(ft,y,'-r',t2,y2,'b.'); grid on
legend('y vs. ft','y_2 vs. t_2'); xlabel('ft, t_2'); ylabel('y(ft), y_2(t_2)');
Compute and plot the autocorrelation of y2(t2):
[r2,lags2]=xcorr(y2,y2,'unbiased');
figure; plot(lags2,r2,'-r.');
xlabel('Lags 2'); title('Autocorr(y_2(t_2))'); grid on
Done.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Correlation and Convolution finden Sie in Help Center und File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by