# Ｌｉｍｉｔ　ａｎｇｌ​ｅ　ｉｎ　［－９０，​９０］　ｄｅｇｒｅｅ

6 ビュー (過去 30 日間)
warnerchang 2022 年 5 月 2 日
コメント済み: Star Strider 2022 年 5 月 3 日
Aｓ　Ｉ　ｗａｓ　ｕｓｉｎｇ　ｏｄｅ４５　ｔｏ　ｓｏｌｖｅ　ＯＤＥｓ，　Ｉ　ｄｏ　ｎｏｔ　ｋｎｏｗ　ｔｏ　ｌｉｍｉｔ　ｔｈｅ　ｒｅｓｕｌｔ　ｉｎ　［－９０，９０］　ｄｅｇｒｅｅ．　Ａｎｙｏｎｅ　ｍａｙ　ｐｒｏｖｉｄｅ　ｓｏｍｅ　ｈｅｌｐ？
##### 3 件のコメント表示非表示 2 件の古いコメント
Star Strider 2022 年 5 月 3 日
I have no idea what the code is, however using 90 times the tanh function could be one way of limiting the angle. This has the advatage of being differentiable rather than using a stepwise limit that would not be differentiable.

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

### 回答 (1 件)

John D'Errico 2022 年 5 月 2 日

You cannot simply constrain an ODE solver to stay within bounds. However, almost certainly, if the ODE solver wants to go outside of those bounds, allow it to do so, because that does not cause a problem. just take the output and then deal with it as a post-processing step.
That is, if X is a vector that ODE45 returns, then use this line of code to remap the predictions back into the [-90,90) interval:
X = mod(X,180) - 90;
For example, that remaps a result that was 91 degrees into -89 degrees. (Note that mod works, even if X is not an integer.)
It would be my guess that this parameter is effectively measuring the slope of a line, in degrees. (It is about the only common reason I can see why you wish to constrain the parameter to lie in that interval.)
And we could argue that the slope of a line must always be between -90 and +90 degrees. But if we had a line with a slope that was predicted to be outside of that interval, then the computation I have provided returns a new slope measure inside the region you wish to see. Effectively, there is no problem. Adding any multiple of 180 degrees does not materially change the slope of a line. (Think about it! You can even prove that claim.)
One thing you really don't want to do is make that change internally in the code, as that could effectively create large discontinuities for the ODE solver to deal with. But changing it after the solver is done is fine.
##### 5 件のコメント表示非表示 4 件の古いコメント
warnerchang 2022 年 5 月 3 日
Ｍａｙｂｅ　Ｉ　ｓｈｏｕｌｄ　ｎｏｔ　ｌｉｍｉｔ　ｔｈｅ　ａｎｇｌｅ，　ａｎｄ　Ｉ　ｗｉｌｌ　ｒｅｖｉｓｅ　ｔｈｅ　ｍｏｄｅｌ．

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

R2018b

### Community Treasure Hunt

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

Start Hunting!

Translated by