differentiation of time series data

I have a time series data 'X 'of size 20000 X 50. My step size dt= 0.05
how do I find the velocity of these data

2 commentaires

Walter Roberson
Walter Roberson le 15 Fév 2021
Extract the data and use gradient() ?
Samson
Samson le 15 Fév 2021
Modifié(e) : Samson le 15 Fév 2021
how do I extract, please? I had something like this but not correct as it is not taken the difference across time:
phdiff=diff(X');
temp=(phdiff./dt);

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 15 Fév 2021
If ts is the timeseries() variable then
X = ts.Data;
extracts the data.
With your data being 20000 x 50 my guess is that you have 20000 measurements for each of 50 entities, rather than 50 measurements for each of 20000 entities. If I am correct, then you would want the y gradient:
xstep = 1; %doesn't really matter, we are going to ignore
tstep = 0.5; %does matter
[~, ygrad] = gradient(X, xstep, tstep); %horizontal step first, vertical step second

18 commentaires

Samson
Samson le 15 Fév 2021
Thank you so much, If I do this it still returns ygrad with same size as before; size 20000 X 50.
Walter Roberson
Walter Roberson le 15 Fév 2021
Yes, that would be expected, that would be the estimated velocities at each of the points. For example if column 1 of the input was the position of the left pinkie finger at each of 20000 times, then column 1 of ygrad would be the estimated velocities at each of the 20000 times. Column 2 might be the velocities of the beanie propeller at each of the 20000 times.
Samson
Samson le 15 Fév 2021
but you know I it to be across rows
I did emphasize my assumption about which way your data was oriented.
xstep = 1; %doesn't really matter, we are going to ignore
tstep = 0.5; %does matter
xgrad = gradient(X, tstep, xstep); %horizontal step first, vertical step second
Samson
Samson le 18 Fév 2021
My data are phase oscillators. I want to determine phase velocity from phase variables. Taking consideration of the peaks; -2pi and +2pi
Walter Roberson
Walter Roberson le 18 Fév 2021
You mean something like unwrap() of angles so that numeric gradients would make sense?
Samson
Samson le 18 Fév 2021
Yes, that is what I mean.
Samson
Samson le 18 Fév 2021
taking consideration of the peaks -2p and +2pi
Walter Roberson
Walter Roberson le 18 Fév 2021
Loop over the appropriate dimension. unwrap() the angles of one particular vector. gradient() the result to get velocities.
Samson
Samson le 18 Fév 2021
If you could help me with the code. The dimension is 50 X 20000 for instance, wherein the angles (Phases) are 50 and 20000 time steps of width 0.05. But if you could give a general code to cover any dimension
Walter Roberson
Walter Roberson le 18 Fév 2021
I do not currently understand what your input is.
What is the difference between data(1,1) and data(1,2) and data(2,1) ? Which dimension is tracking time? What dimension do you need to take the gradient over? What is the other dimension ?
Is it correct that the values stored in the data are angles?
Samson
Samson le 18 Fév 2021
The second dimension is tracking time. I need say,the last 2500 time unit. The other dimension are the angles stored in radians.
Walter Roberson
Walter Roberson le 18 Fév 2021
So rows correspond to fixed angles and columns correspond to time? If so then what do the values represent, and why would you you need to do angle wrapping?
Or is it the case that the first dimension represents a physical angle and the values represent phases in terms of a different kind of angle than the angle for the first dimension? A signal angle for example rather than a physical angle?
Samson
Samson le 18 Fév 2021
The row are actually oscillators represented in terms of phase values. So basically I want to determine mean phase velocity from the phase variables
this was something I gathered but do not know how well to arrange. I am actually new to matlab
% function phvelo= phase_velo(X,dt)
% phvelo=diff(X');
% phvelo(phvelo>pi)= phvelo(phvelo>pi)-2*pi;
% phvelo(phvelo<-pi)= phvelo(phvelo<-pi)+2*pi;
% phvelo=phvelo';
% phvelo=phvelo'./dt;
%
% end
% omegav=mean(phvelo);
% omega=max(omegav)-min(omegav);
%
Walter Roberson
Walter Roberson le 21 Fév 2021
I do not understand your data arrangement.
Do the columns correspond to time?
Is it the columns that you need to take the phase velocity of, by taking the gradient of phase angles?
Are the values in the array pure angles, or are they complex values in which the angle must be calculated?
When angle unwrapping needs to be done, is that only over the columns?
Can the data be treated as a series of independent columns?
Samson
Samson le 21 Fév 2021
It is the row that correspond to time. I am taking the velocity across the row which is a dimensionless time uniit. The values are phase values of oscillator distribeted in the interval (0,2pi]. I would finally need the mean of the phase velocity as there all independent rows
xstep = 1; %doesn't really matter, we are going to ignore
tstep = 0.5; %does matter
Xunwrapped = unwrap(X, [], 2);
[~, velocity_gradient] = gradient(Xunwrapped, xstep, tstep); %horizontal step first, vertical step second

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2019b

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by