To find the auto correlation of the finite length sequence x(n)=[1 4 1 3] in Matlab, we can use the xcorr
function. Here is the code:
main.m345 chars19 lines
This code first defines the sequence x
. It then calculates the autocorrelation of x
using the xcorr
function. Finally, it plots the input sequence and the autocorrelation using the stem
function, with appropriate titles and labels.
The resulting plot should show the input sequence as a stem plot, and the autocorrelation as another stem plot, with the same number of samples as the input sequence.
gistlibby LogSnag