OK, confirmed: The the last number (1.195) shall be displayed as 1.20, otherwise a meticulous scientist looses information... :)
num2str([1.105, 1.115, 1.125, 1.135, 1.145, 1.155, 1.165, 1.175, 1.185, 1.195],3)
ans =
1.11 1.12 1.13 1.14 1.15 1.16 1.17...
I expected a failing around 1.15, but there is nothing surprising, IMO.
A part of your idea:
num2str([1.145, 1.155],2)
ans =
1.1 1.2
IMO, it is OK.
A new failing example:
num2str([1.145, 1.150, 1.155],2)
ans =
1.1 1.1 1.2
<=> rounding 1.15 to the first decimal place...
Dear Users,
the topic MATLAB num2str is closed, therefore I am posting this as a reply to that thread.
The suggestion by marcusl won't work for numbers of various format, but same number of valid digits. Example: The numbers
0.0056
0.0060
0.043
0.050
0.32
0.40
are valid to their...