フィルターのクリア

round numeric 0

1 回表示 (過去 30 日間)
Pinco
Pinco 2012 年 1 月 17 日
Hi everyone! I have a matrix like this:
A=[ 1 , .3*10^-8 , .2*10^-8 , .2*10^-8;
. 3*10^-8; 1; .2*10^-8;
.2*10^-8, .2*10^-8, 1];
I want 0 (real or integer) where i have a very very very small value. How can I do it?
I know I can use logical mask
A(A<10^-7=0)
but i'm looking for a matlab function that can do automatically. This is a typical numeric problem...
Thanks a lot for you answer.
Pippo

採用された回答

Andreas Goser
Andreas Goser 2012 年 1 月 17 日
This is actually done automatically if it is very very very small. But it looks the veryveryvery is different for you. The
eps
Function return what MATLAB sees as small enough to be rounded to zero.
Besides your own suggestion (probably think also of negative small values, you may use all kinds of rounding and formatting like
round
sprintf
depending on your needs.

その他の回答 (1 件)

Jaap
Jaap 2012 年 1 月 17 日
your best option:
A(A<small_value) = 0
you can also try:
A = A(bsxfun(@lt,A,1E-7))
I doubt its quicker.
  1 件のコメント
Jaap
Jaap 2012 年 1 月 17 日
you get the point

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeScope Variables and Generate Names についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by