Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12810

Re: silly question on formatting tables

From Ray Koopman <koopman@sfu.ca>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: silly question on formatting tables
Date 2012-12-16 06:06 +0000
Message-ID <kajodj$im0$1@smc.vnet.net> (permalink)
References <kaem93$5qp$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


On Dec 13, 11:59 pm, alba.may...@gmail.com wrote:
> Dear all,
>
> Consider the matrix
>
> {{0, 0, 1.19092}, {0.883038, 0, 0.366804}, {0, 0, 0}}
>
> How can I display it in matrixform/tableform so that the integers are displayed as integers and the reals are displayed only with 2 decimals?
>
> If I use MatrixForm, the reals are displayed with 6 decimals, and if I use TableForm all numbers, including integers are displayed with 2 decimals.
>
> Thanks!

mat = {{0, 0, 1.19092}, {0.883038, 0, 0.366804}, {0, 0, 0}};

Map[NumberForm[#,If[IntegerQ@#,3,{3,2}]]&,mat,{2}] //TableForm

0      0   1.19
0.88   0   0.37
0      0   0

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

silly question on formatting tables alba.maydeu@gmail.com - 2012-12-14 07:59 +0000
  Re: silly question on formatting tables Peter Breitfeld <phbrf@t-online.de> - 2012-12-15 10:47 +0000
  Re: silly question on formatting tables Ray Koopman <koopman@sfu.ca> - 2012-12-16 06:06 +0000

csiph-web