Solve simple equation with the floor function.

S and P are known element in the equation. I want to find x
S = 10;
P = 13;
S = floor(P*(1-x))
I do not know how to deal with the floor functions.

 採用された回答

Matt J
Matt J 2021 年 4 月 28 日
編集済み: Matt J 2021 年 4 月 28 日

0 投票

It is the same as solving
S+delta=P*(1-x)
where 0<=delta<1 is arbitrary. The solution is then,
x=1-(S+delta)/P
It's important to keep in mind if you are solving this numerically that delta=0 will be a numerically unstable choice because the resulting x will take you close to the discontinuity of the floor function.
Let's test with delta=0.5:
S = 10;
P = 13;
delta=0.5;
x=1-(S+delta)/P
x = 0.1923
S == floor(P*(1-x)) %check
ans = logical
1

1 件のコメント

NA
NA 2021 年 4 月 29 日
Thank you for your time

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeNumerical Integration and Differential Equations についてさらに検索

質問済み:

NA
2021 年 4 月 28 日

コメント済み:

NA
2021 年 4 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by