MATLAB: To find four-digit numbers after comma

find numbermatrix

Hello,
I am trying to find first 1,2,3,4 digit numbers after the comma in the matrix below. The numbers with more than 4 digit have to be eliminated. How can I find this numbers?
a = [0.0001255 0.0212215 0.20222022 0.9805446;
0.0222 0.2026454 0.0100 0.98052516;
0.0010 0.002 0.1 0.2000;
0.23156498 0.6545648 0.467823 0.9876564];
However, all numbers must be in the same row. For example, a (2, 🙂 should not be selected.

Best Answer

sprintf('%.99g', 0.0222)
ans =
'0.0222000000000000009825473767932635382749140262603759765625'
*None* of the entries in your matrix are 4 digits after the decimal. MATLAB does not store floating point numbers in decimal, and there is no exact finite binary floating point representation of 0.1. The *only* binary floating point values that are four digits after the decimal point are
0.0625 0.1875 0.3125 0.4375 0.5625 0.6875 0.8125 0.9375