Adding to or Subtract From a Specifc Array Element Based on Size or Magnitude Condition

1 次查看(过去 30 天)
I am comparing the deltas between two compass readings and both compasses are measured from 0 degrees up to 359.99 degrees. When I have a reading on Compass 1 to be 0 degrees and Compass 2 is just 2 degrees off at 358.0, the Delta (Comp2 - Comp1) is (358 - 0) or 358 degrees, but in actuality, it is only a 2 degree difference. If I perform the delta the other way (Comp1 - Comp2), I get -358 degrees. I want to initiate a condition within my program to evaluate the delta readings for the compasses and any delta over a large value, say 180 or -180 degrees, to subtract or add 360 degrees depending on the sign of the result. Can you tell me how I can do this within my delta array?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by