Hi Marco Aratiano,
I understand that you want to use correlation on two matrices at a reference point on different steps. I would suggest you use column vector approach on matrices as follows:
% Loop through each time step
for t = 1:numTimeSteps
% Extract the values at the reference point for the current time step
phi_ref = phi(xr, yr, zr, t);
psi_ref = psi(xr, yr, zr, t);
% Compute the cross-correlation between phi and psi at the reference point
correlation = corrcoef(phi_ref(:), psi_ref(:));
R = correlation(1, 2);
% Extract the cross-correlation coefficient
% Store the cross-correlation coefficient for the current time step
R_values(t) = R;
end
You can take the mean of ‘R_values’ to finally find the correlation. For more information on corrcoef, go through the below link:
- https://in.mathworks.com/help/releases/R2023a/matlab/ref/corrcoef.html
Thank you,
Abhimenyu

