Numerical Garbage value in Matrix
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I have two n*n matrices and I am computing their sum. The sum is
[124.449917129290 + 0.00000000000000i -43.6298898009808 - 7.10542735760100e-15i -43.6298898009808 + 7.10542735760100e-15 i 124.449917129290 + 0.00000000000000i]. The bold value should be zero as I am using this result in an optimization problem and these 7^(-15) terms are introducing numerical garbage in my optimization problem. Any suggestions on how to make these terms exact zero when I perform the sum of matrices?
2 件のコメント
KALYAN ACHARJYA
2018 年 10 月 17 日
Can you clarify more, why zero, its doesn't affect in sum value, (+ and - equal value cancel each other)?
回答 (1 件)
John D'Errico
2018 年 10 月 17 日
編集済み: John D'Errico
2018 年 10 月 17 日
help real
Better yet, compare the results of abs(real(A)) to abs(imag(A)). As long as the imaginary part is small, just delete it, replacing the value with real(A).
If abs(imag(A)) is ever too large, then raise a stink, since then you arguably have a problem that cannot just be dismissed as floating point trash. But at least then you know if there was a problem.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!