I suppose you can convert to string with desired number of digits and convert back to number.
example:
b = sprintf('%.2f', 12345.6785) % I ask for 2 digits here
b =
12345.68
>> str2num(b)
ans =
1.234568000000000e+004
Walter Roberson <roberson@hushmail.com> wrote in message <ic6th4$6tl$1@canopus.cc.umanitoba.ca>...
> On 101119 04:05 PM, Eman wrote:
>
> > how can I determine the number of digits after the decimal point?
> > I mean:
> > If I need 2 digits after decimal point, If a=74.67859 it should be a=74.68
> > If I need 3 digits after decimal point, If a=74.67859 it should be a=74.679
> > note: I need to use the new value not only format them in printing.
>
> The only way to do that is to use symbolic numbers with the symbolic toolkit,
> or fixedpoint numbers with the fixedpoint toolbox.
>
>
> You can use transformations such as
>
> round(a .* 10^D) ./ 10^D
>
> where D is the number of digits you want after the decimal place. This will
> not, however, round to *exactly* 74.68: it would instead round to
> 74.68000000000000682121026329696178436279296875
>
> When you use binary floating point numbers, the only numbers with two decimal
> places that can be *exactly* represented are those that end in .0, .25, .5, or
> .75 . It is not possible, for example, to exactly represent 0.1 in binary
> floating point: the closest you can get would be
> 0.1000000000000000055511151231257827021181583404541015625
