hi. im new in MATLAB.
i think its a simple question.
i want:
a=1.154648126486416
to become
a=1.154
and not
a=1.54000000000
how do i do that without useing format('bank').
thanks.
views:
40answers:
2
+1
A:
Building on @gnovice's answer, you can format the output as a string to get rid of the extra zeros. See the sprintf
documentation for all the formatting options.
str=sprintf('The result is %1.3f.',a);
disp(str)
will show "The result is 1.154." in the command prompt. Or write the string to file, etc., etc.
Doresoom
2010-06-07 14:49:21