How can I recognize symbolic value with actual value 0?

조회 수: 1 (최근 30일)
Hansol Lee
Hansol Lee 2020년 5월 3일
댓글: Hansol Lee 2020년 5월 3일
I was making some calculation and got symbolic value of
ans =
3/2 - (73^(1/2)/4 - 7/4)*(73^(1/2)/4 + 7/4)
it was actually 0, but matlab didn't recognize it. I used double(syms), but the result was
ans =
-4.5278e-72
how can I make matlab recognize it as 0?

채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 3일
simplify() the expression

추가 답변 (1개)

Paresh yeole
Paresh yeole 2020년 5월 3일
You need to specify custom tolerance.
if abs(ans) < 1e-10
ans = 0;
end
You can specify your own tolerance instead of 1e-10.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by