2 Ansichten (letzte 30 Tage)
Jorge Calderon
Jorge Calderon am 13 Jun. 2021
Bearbeitet: madhan ravi am 13 Jun. 2021
I just need to do a simple math operation (9.2 x 9.2), wich result is 84.64. But somehow MATLAB give me a 84.699999999990 result I don't know why, I need the exact result of the operations because this result makes my servomotor go +90°, and wuth 84.64 it goes -90°.
Both q3b4 and q3b5 have the same result.

Antworten (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 13 Jun. 2021
MATLAB's accuracy is not absolute and thus, such offsets will be present. You can select how many decimal digits you need using vpa() if you have Symbolic MATH toolbox.,32%20digits%20by%20using%20digits%20.

madhan ravi
madhan ravi am 13 Jun. 2021
Bearbeitet: madhan ravi am 13 Jun. 2021
Click on the tag floating-point
round((9.2^2 * 1e2) / 1e2, 3) % since you're using a hardware , not sure using a sym class would be acceptable for it
ans = 84.6400

Community Treasure Hunt

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

Start Hunting!

Translated by