MATLAB Answers

Making heading data continuous (i.e. instead of 359 --> 0 degrees make it 359 --> 360 degrees)

조회 수: 2(최근 30일)
Amritz Ansara
Amritz Ansara 2021년 5월 11일
댓글: Amritz Ansara 2021년 5월 12일
I have a spreadsheet containing data about a vehicle's speed and heading against time. The spreadsheet is attached. When plotting the heading of the vehicle against time, I get this plot:
As can be seen, the near-vertical lines are mostly because the vehicle's heading changes from 359 degrees to 0 degrees (and vice versa) which makes the bearing look discontinuous. How could I make it such that the vehicle heading data reads, say, 360 degrees, 361 degrees, etc? I need it as it's easier for me to then calculate through what angle a vehicle has turned.
Please let me know if you need any clarification.
To get the plot above, my code is:
A = readmatrix("20181026075227_947BE7249B00.csv");
%find initial time, since time is in UNIX millisecond format.
%column 1 is the time, column 6 is the bearing
t0 = A(1,1);
plot((A(:, 1)-t0)/1000, A(:, 6), 'LineWidth', 3)
ylabel("Heading (degrees)")
xlabel("Time from start (s)")

채택된 답변

Chunru
Chunru 2021년 5월 12일
Try this:
plot(rad2deg(unwrap(deg2rad(BE7249B00{:, 6})))); % The data is 6th column
  댓글 수: 1
Amritz Ansara
Amritz Ansara 2021년 5월 12일
This works well for me and is what I had in mind originally - thank you!

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Geoff Hayes
Geoff Hayes 2021년 5월 12일
Amritz - perhaps a polarplot might be useful:
polarplot(headingData*pi/180.0, (A(:, 1)-t0)/1000);
  댓글 수: 1
Amritz Ansara
Amritz Ansara 2021년 5월 12일
While this wasn't in my mind originally, no doubt I'll find this useful in the future. It's also quite informative too. Thank you!

댓글을 달려면 로그인하십시오.

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by