Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: silly question on formatting tables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129104] Re: silly question on formatting tables
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Sat, 15 Dec 2012 05:51:05 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20121214080121.1B6FF694F@smc.vnet.net>

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

(dataFormatted = data /.
    x_Real :> NumberForm[x, {4, 2}]) //
 Grid

dataFormatted // TableForm

dataFormatted // MatrixForm


Bob Hanlon


On Fri, Dec 14, 2012 at 3:01 AM,  <alba.maydeu at 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!
>



  • Prev by Date: Re: Problem with PlotLegends
  • Next by Date: Re: silly question on formatting tables
  • Previous by thread: Re: silly question on formatting tables
  • Next by thread: Re: silly question on formatting tables