Solve simple equation with the floor function.

8 views (last 30 days)
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.

Accepted Answer

Matt J
Matt J on 28 Apr 2021
Edited: Matt J on 28 Apr 2021
It is the same as solving
where 0<=delta<1 is arbitrary. The solution is then,
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;
x = 0.1923
S == floor(P*(1-x)) %check
ans = logical

More Answers (0)


Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by