Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: how to round value in matrixs

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


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[3] onto the
elements of mat at level 2).

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

David Park
djmp at

> From: Tomasz [mailto:tomaszmach at]
To: mathgroup at
> 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