I know about MATLAB\'s format long, format short, eng ... and so on. But short and long will always display a predefined number of decimals, with
There are two simple solutions:
using the sprintf function:
str = sprintf('%.4f', myNumber);
using Java-based formatting, which is much more powerful (more information):
str = char(java.text.DecimalFormat('#.0000').format(myNumber));