How do handle wrapped angular data in timetable? VariableContinuity?
12 vues (au cours des 30 derniers jours)
In a timetable, you can have wrapped angular data such as wind direction. The data is continuous in that it smoothly changes, but has numerical discontinuities whenever it crosses 359 to 0 or 0 to 359.
I know of the solutions that I could unwrap the data first; so instead of 359 to 0 it does 359 to 360, 361 etc. I could also split the data into seperate sin and cos components.
However, in my data set I want the data to remain wrapped because it makes sense that way. But if I call a function to process the data, for example to resample it, I want that function to recognize that this variable is wrapped so that the function acts accordinging (for example by unwrapping the data, then resampling, then re-wrapping the output).
Timetable already has a VariableContinuity property would be perfect for this. The angular data could be marked as 'wrapped', or better yet it could identify how it is wrapped like 0to360 to -180to180 or (or -pi to pi or 0 to 2pi for radians). Functions could then query this property and act accordingly.
I know I could use custom properties, but they won't work with many of the existing matlab functions for timetables, like resampling. So I'm back to writing all this myself.
Are there tools for handling wrapped angular data? If not, could they be added?
Manoj Mirge le 21 Fév 2023
I think the function you are looking for is unwrap . unwrap(P) function unwraps the radian phase angles in a vector P. Whenever the jump between consecutive angles is greater than or equal to π radians, unwrap shifts the angles by adding multiples of ±2π until the jump is less than π.
You can read more about the unwrap function here : https://www.mathworks.com/help/matlab/ref/unwrap.html
So in your case you can store angular data of wind direction in radians in your timetable. Also you can store that angular data in wrapped state in your timetable. Before giving your timetable to functions (like retime etc.) for processing on it you can just unwrap your angular data column from timetable.
Tt;% Your Timetable
Tt1=Tt; %Copy the timetable into some other timetable in which you can unwrap the angular values.
Tt1.Angle=unwrap(Tt1.Angle); % Unwrap the angular values
Tt_processed=retime(Tt1,optional arguments);%Tt_processed table will be your required timetable.
Hope this will help you.