Search code examples
matlabnumerical

how to ignore relatively small values in matrices calculations in matlab


Let's say we have a matrix A=[1 0 0; 0 2 0; 0.00001 0.000002 0.00003] in Matlab. Do you know how to ignore (consider as 0) the small values in it when calculating the rank for example? what i need is a general solution to such problems!


Solution

  • So... pick a threshold and set anything below that to 0?

    threshold = 0.0001;
    A(A < threshold) = 0
    

    Or else depending on the rest of A you could just round off:

    floor(A) %// or round(A) or fix(A)...