필터 지우기
필터 지우기

accuracy n precision

조회 수: 3 (최근 30일)
Twinkle
Twinkle 2011년 9월 26일
what do i do so that the result of cos(pi/2) is zero?

채택된 답변

Jan
Jan 2011년 9월 26일
Calculations with DOUBLEs involve rounding errors due to the limited precision. There is nothing you can or should do about it but taking it into account. Using COSD "helps" for this specific case, but only by rounding the small result to zero by accident.
Reliable numerical methods do never rely on a certain result of a calculation. Using an interval is much saver:
if cos(x) == 0 % Bad, unpredictable results!
if abs(cos(x)) < 10 * eps % Save
See also:

추가 답변 (1개)

UJJWAL
UJJWAL 2011년 9월 26일
Hi
The problem with MATLAB is its precision in these cases. You can try like this .
cosd(x * (180/pi));
% Where x is the angle in radians
This will give you the correct result.
For example when x = pi/2 then cosd (pi/2 * 180/pi) = 0

카테고리

Help CenterFile Exchange에서 Discrete Math에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by