how to integrate angle in matlab

3 ビュー (過去 30 日間)
Bhargav Jha
Bhargav Jha 2015 年 8 月 18 日
コメント済み: Bhargav Jha 2015 年 8 月 20 日
Hi! I have these three state equations:
x_dot = v*cos(alpha);
y_dot = v*sin(alpha);
alpha_dot = lateralAcceleration/v;
I have to integrate these states to get x,y and alpha. I am implementing this on simulink. But I am facing a problem that while integrating the angle alpha goes to a very large number. I need it to be in a certain range such as range of atan2. Is there a way to do it?
I have attached the image which shows my current implementation.

採用された回答

JMP Phillips
JMP Phillips 2015 年 8 月 19 日
If alpha_dot is going very large, you could consider filtering or smoothing out the large jumps.
You can put a saturation block in to limit your alpha_dot between lower and upper values: http://au.mathworks.com/help/simulink/slref/saturation.html
Alternatively or additionally you can insert a gain block: alpha_dot = k*lateralAcceleration/v where k is a proportional gain that you can tune such that alpha_dot is within an acceptable range.
After you integrate alpha_dot to get alpha you need to wrap it between -pi and pi or 0 and 2 pi, whatever convention you are using, using mod, e.g.
angle_wrapped = ( mod( (angle-angle_min),(angle_max-angle_min)) +angle_min);
I don't remember if Simulink already has a wrap block, but there is already a wrapToPi function in the mapping toolbox if you have that.
  1 件のコメント
Bhargav Jha
Bhargav Jha 2015 年 8 月 20 日
Hello, I used wrapto2Pi function in matlab function block and that solved my problem.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by