Problem about rounding to 0
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
I have a function w=u_1*u_2-u_3*u_4.
u_i's are also functions that return complex double numbers.
For some inputs i get the result w=0 (in workspace, not only in command window) which is a result that i dont like for my analysis (cause later i have to devide some numbers with it).
But when i compute the u_i's seperately and i do the operation u_1*u_2-u_3*u_4 (using the u_i results from workspace) i get a result like ''1.6941e-20 - 2.1684e-19i'' which is of course very small but different to 0.
Why dont i see this result for w instead of 0? How can i fix this ? Is it a rounding to 0 problem ?
댓글 수: 1
James Tursa
2020년 7월 30일
Please provide an example set of inputs and desired output.
답변 (1개)
madhan ravi
2020년 7월 30일
w = u_1 * u_2 - u_3 * sym(u_4)
Click on the tag floating-point.
댓글 수: 2
Dimitris Sarvanis
2020년 7월 30일
madhan ravi
2020년 7월 30일
Set tolerance.
w(real(w) < 1e-2 & imag(w) < 1e-2) = 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!