Autocorrelation of data in a matrix
Show older comments
Hi, How do I find the autocorrelation of data given in 2D matrix?
Eg: A matrix a(x,y) is given. I need to find the autocorrelataion w.r.t y.
Thanks in advance.
1 Comment
Image Analyst
on 18 Feb 2013
Explain what you mean. Usually a 2D auto-correlation is done in both directions. Are you saying that you want correlation only vertically along the y axis?
Answers (1)
Youssef Khmou
on 18 Feb 2013
Edited: Youssef Khmou
on 18 Feb 2013
Hi Nida,
1) If you are talking about 2D Autocorrelation :You can use the function "xcorr2". example :
A=1.33*randn(40,40); % Bidimensional Gaussian process
y1=xcorr2(A);
y2=xcorr2(A,A); % y1 and y2 are the same ,
2) If you mean computing the autocorrelation of columns of matrix A(N,P) which means that you have P signals each of length N then :
*1) You can use "xcorr(A)" but you get a (2*N-1)xP² with autocorrelations and crosscorrelations of all P signals .
*2) You can only compute the autocorrelation of each signal using loop :
% given a matrix data A of size (n,p)
n=20;p=5; % you have 5 signals
A=randn(n,p); % data
C=zeros(2*n-1,p); % matrix containing 5 autocorrelations of 5 signals
for i=1:p
C(:,i)=xcorr(A(:,i));
end
1 Comment
Rohan Majumder
on 4 Sep 2019
How to plot the 2D autocorrelation with lag?
Categories
Find more on Correlation and Convolution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!