working with angles and wraparound

31 ビュー (過去 30 日間)
michael
michael 2023 年 7 月 5 日
コメント済み: michael 2023 年 7 月 5 日
Hi,
I have an antenna (the black dot) which is receiving pointing commands and sends pointing report.
Also I have a moving object around the antenna (the red line).
I'd like to compare the analytical analysis with the command and the report.
the issue is that when I cross from 360 to 0 I'll have a "spike" on the delta graph (of the command-report).
How to overcome the issue so that the transition would be smooth?

回答 (1 件)

Pramil
Pramil 2023 年 7 月 5 日
To overcome the issue of a "spike" in the delta graph when crossing from 360 to 0 degrees, you can use the concept of angular wrapping or circular arithmetic. This involves adjusting the values to ensure a smooth transition when crossing the 360-degree mark.
Here's an example of how you can implement angular wrapping in MATLAB:
% Generate sample data
command = [355, 358, 2, 5, 358, 1, 3, 6, 359, 2, 4, 357];
report = [354, 357, 3, 6, 357, 0, 2, 5, 358, 1, 3, 356];
% Convert the angles to the range [0, 360)
command_wrapped = mod(command, 360);
report_wrapped = mod(report, 360);
% Calculate the delta between command and report
delta = mod(report_wrapped - command_wrapped, 360);
% Plot the delta graph
plot(delta);
xlabel('Sample');
ylabel('Delta');
title('Command-Report Delta');
  1 件のコメント
michael
michael 2023 年 7 月 5 日
Your example is not good. in the delta you shall have in the first place difference of 1, rather than 359 degress
Also, put in report [354 357 359 ...]
This is more realistis scenario - the difference is

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGeoscience についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by