       RE: how to round value in matrixs

• To: mathgroup at smc.vnet.net
• Subject: [mg31872] RE: [mg31835] how to round value in matrixs
• From: "David Park" <djmp at earthlink.net>
• Date: Sat, 8 Dec 2001 05:51:50 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Tomasz,

Here is a function which will round an approximate number to n places.

round[n_][num_] := N[Round[10^n*num]/10^n]

Here is a randomly generated matrix.

mat = Array[Random[] &, {2, 2}]
{{0.39248, 0.541335}, {0.236583, 0.330804}}

This rounds the matrix elements to 3 places (by Mapping round onto the
elements of mat at level 2).

roundedmat = Map[round, mat, {2}]
{{0.392, 0.541}, {0.237, 0.331}}

David Park

> From: Tomasz [mailto:tomaszmach at poczta.onet.pl]
To: mathgroup at smc.vnet.net
>
> Hi
> I use Mathematica 4.0 and I would like to know how I can to round matrix
> values becouse I calculate in Mathematica matrix which include number with
> 13 digits after point but a would like to 3 digits after point
> how do this .
> thanks for all
>
>
>

```

• Prev by Date: RE: tangents and their respective equations
• Next by Date: RE: PowerExpand in mathematica
• Previous by thread: how to round value in matrixs
• Next by thread: Re: how to round value in matrixs