xcorr results: c written in long format, lags in wide format

1 view (last 30 days)
I want to calculate the cross-correlation between ankle and hip movement.
My data are organised in a structure: model.filt.modelOutputs with 12500x3 matrices.
I attached an example file with only the filtered Ankle and Hip angles.
The data contains several movement cycles which can be identified by the starting frames stored in tStart.
When I use [c, lags] = xcorr, I get c as 1301x1 double and lags as 1x1301 double.
Can anyone explain, why this happens? When I use different example vectors, both results have the same orientation.
This is the part of my code, which reproduces the results::
load modelExample.mat
tStart = [1,611,1261];
[c, lags] = xcorr(modelExample.filt.RAnkleAngles(tStart(2):tStart(3),2), modelExample.filt.RHipAngles(tStart(2):tStart(3),2), 'normalized');

Accepted Answer

DGM
DGM on 13 Dec 2023
I don't see it documented anywhere, but lags is always a row vector, regardless of the orientation of the input.
If you want it to match the orientation, you can always either transpose or reshape it as needed.
  2 Comments
Torsten Pohl
Torsten Pohl on 13 Dec 2023
Hi DGM,
thank you for your answer. I already have a working solution for my code. I just wanted to understand, if there is a specific reason for it.
DGM
DGM on 13 Dec 2023
I'm really not the one to ask for reasons. If you look in xcorr, lags is simply calculated as
lags = -maxlag:maxlag;
which is a row vector. That's all I know.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!