How to calculate the Pathlength of a function where -180 degrees is next to 180 degrees?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
luc
am 12 Aug. 2015
Beantwortet: Walter Roberson
am 13 Aug. 2015
Hey everyone!
I'm using the pathlength function to calculate some average changes in my data, but this does not take into account that -180 degrees = 180 degrees (ofcourse it doesn't do this as it's not programmed for that). So, my question is: How to make sure the pathlenght is calculated correctly.
Small example:
Data_1=[1 0; 2 1]; % [time, roll] The path length function gives me "1", as we've moved 1 degree.
Now we move 1 degree but then in the -180 to 179 range.
data_2=[1 -180; 2 179]; %[time, roll]
The path length function tells me the change is 359 instead of 1 degree.
0 Kommentare
Akzeptierte Antwort
Adam
am 12 Aug. 2015
Is it not just:
min( [len 360-len] )
where len is the result of your pathlength function?
0 Kommentare
Weitere Antworten (1)
Walter Roberson
am 13 Aug. 2015
The function you linked to is an arclength function that takes x and y coordinates not time and degrees. Are you certain that you linked to the correct function?
If you have angles in general you should make the sequence continuous by using unwrap(). unwrap() expects radians so if you have degrees,
angle_continuous_degrees = unwrap(angle_degree_vector * pi / 180) * 180 / pi;
You should be considering:
[data_x, data_y] = pol2cart( unwrap(YourData(:,2) * pi / 180), YourData(:,1) );
arclength(data_x, data_y)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!