rounding to zero small numbers (NOT round function)

조회 수: 64 (최근 30일)
atabak mostafavi
atabak mostafavi 2019년 10월 30일
댓글: Walter Roberson 2019년 10월 31일
hey
so i want matlab to consider every number below a certain level (for example 0.001) as zero in the whole script. while right now it returns some computation result even in 10e-15, is there any defult value for matlab ?

답변 (1개)

dpb
dpb 2019년 10월 30일
No. ML basic numeric type is the floating point double which around zero has roughly the above magnitude of precision.
You'll have to set values less than your chosen threshold to zero explicitly.
The round function with the optional second option could be useful tool in this, but simply
x(x<threshold)=0;
will avoid the rounding that occurs in it. Of course, you'll want to use abs to get both positive and negative sides of the rounding that will likely occur.
You might also find ismembertol of use depending upon your actual code.
  댓글 수: 9
atabak mostafavi
atabak mostafavi 2019년 10월 31일
ok when I excute this:
det(B)
coeff_sol=null(sym(B))
I get this:
ans =
-8.7503252381931774667359844484583e-38
coeff_sol =
Empty sym: 1-by-0
Walter Roberson
Walter Roberson 2019년 10월 31일
I would be interested to see what shows up for
dets = det(sym(B))
detn = double(dets)
However for large B this can take a fair while.
You might want to look at https://cseweb.ucsd.edu/classes/wi15/cse252B-a/nullspace.pdf at how null space can be determined by SVD. That form would give you the flexibility to permit columns that you consider "close enough" to zero.

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by