Is it possible to find autocorrelation function of a piecewise function?

조회 수: 5 (최근 30일)
syms yt(t);
yt(t) = piecewise(1<t <3, 1, 3 < t < 4, -1, 0);
figure
subplot(2,1,1)
fplot(yt)
subplot(2,1,2)
auto = autocorr(yt);
fplot(auto)
I am trying to find the autocorrelation function of a piecewise function but none of the commands seem to work because it is of type syms. I there any way around this?

채택된 답변

Dimitris Kalogiros
Dimitris Kalogiros 2018년 9월 30일

You have to calculate autocorrelation using its definition :

clear all; close all; clc;  
syms  yt(t) tau t;
    % our signal
    y(t) = piecewise((1<t) & (t<3), 1, (3<t) & (t<4), -1, 0)
    %autocorrelation R(t)
    syms R(t)
    R(tau)=int(y(t)*y(t+tau), t, -20, 20)
    % plot results
    figure
    subplot(2,1,1)
    fplot(y, 'LineWidth', 3); grid on
    xlabel('t'); ylabel('y(t)'); title('Signal');
    subplot(2,1,2)
    fplot(R, 'LineWidth', 3, 'color', [0 .5 0]); grid on;
    xlabel('tau'); ylabel('R(tau)'); title('Autocorrelation');

...and you will get this:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by