Based on @gnovice's answer, you can format the output as a string to get rid of extra zeros. See the documentation sprintffor all formatting options.
str=sprintf('The result is %1.3f.',a);
disp(str)
will show: "The result is 1.154." on the command line. Or write a line to a file, etc. Etc.
source
share