Hi there, I need to correct aberrant IMU euler orientation values occurring secondary to Gimbal lock.

3 次查看(过去 30 天)
I essentially have half the signal oscillating around the 0 degree mark and the other half around the 360mark. As true values will never exceed 180, I thought I could correct the output by reassigning all values > 360 to their original value subtracting 360. I have tried
Array Variable = yaw
yaw(yaw>180)=yaw-360
But this doesn't work, any have any ideas to correct this in an elegant way?

回答(3 个)

David Ding
David Ding 2017-10-18
Hi Luckshman,
I understand that you are trying to limit your angle data to between 0 and 360 degrees. You may make use of the "mod" function to take all your data modulo 360. For example:
% raw data
>> x = randi(500, 10, 1)
x =
346
158
344
418
10
376
495
375
141
395
Corrected data by setting all angles > 360 to their corresponding values < 360:
y = mod(x, 360)
y =
346
158
344
58
10
16
135
15
141
35
This is also more robust than subtraction by 360 because for example if an angle is > 720 (i.e. two revolutions), the angle can still be brought back accordingly to the value between 0 and 360.
More information about MATLAB's "mod" function can be found below:
Best,
David

James Tursa
James Tursa 2017-10-18
编辑:James Tursa 2017-10-18
The code you were using was not working because the rhs yaw was not indexed. E.g., to correct this
yaw(yaw>180) = yaw(yaw>180) - 360;

Luckshman Bavan
Luckshman Bavan 2017-10-27
Thank you James and David! Both responses were very clear and helpful.

类别

Help CenterFile Exchange 中查找有关 Matched Filter and Ambiguity Function 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by