help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Properly formatting matrices in Octave


From: AMG
Subject: Properly formatting matrices in Octave
Date: Mon, 4 Nov 2013 10:35:50 -0800 (PST)

Hello,

This might sound like a very basic question, but I've been struggling to
find how to properly format a matrix in Octave.

I want to display the values of a matrix using 2 decimal digits AND the
numbers in columns aligned on the decimal point. So far, "format bank" gives
me the closest output that I want, but displays the numbers in a rather
messy way.

Here's an example:

octave:71> format bank
octave:72> Ua
Ua =

  -0.22  -0.11  0.29  -0.41  -0.11  -0.34  -0.52  0.06  0.41
  -0.20  -0.07  0.14  -0.55  0.28  0.50  0.07  0.01  0.11
  -0.24  0.04  -0.16  -0.59  -0.11  -0.25  0.30  -0.06  -0.49
  -0.40  0.06  -0.34  0.10  0.33  0.38  -0.00  0.00  -0.01
  -0.64  -0.17  0.36  0.33  -0.16  -0.21  0.17  -0.03  -0.27
  -0.27  0.11  -0.43  0.07  0.08  -0.17  -0.28  0.02  0.05
  -0.27  0.11  -0.43  0.07  0.08  -0.17  -0.28  0.02  0.05
  -0.30  -0.14  0.33  0.19  0.11  0.27  -0.03  0.02  0.17
  -0.21  0.27  -0.18  -0.03  -0.54  0.08  0.47  0.04  0.58
  -0.01  0.49  0.23  0.02  0.59  -0.39  0.29  -0.25  0.23
  -0.04  0.62  0.22  0.00  -0.07  0.11  -0.16  0.68  -0.23
  -0.03  0.45  0.14  -0.01  -0.30  0.28  -0.34  -0.68  -0.18

What I would like to see is this:
Ua =

  -0.22  -0.11   0.29  -0.41  -0.11  -0.34  -0.52   0.06   0.41
  -0.20  -0.07   0.14  -0.55   0.28   0.50   0.07   0.01   0.11
  -0.24   0.04  -0.16  -0.59  -0.11  -0.25   0.30  -0.06  -0.49
  -0.40   0.06  -0.34   0.10   0.33   0.38  -0.00   0.00  -0.01
  -0.64  -0.17   0.36   0.33  -0.16  -0.21   0.17  -0.03  -0.27
  -0.27   0.11  -0.43   0.07   0.08  -0.17  -0.28   0.02   0.05
  -0.27   0.11  -0.43   0.07   0.08  -0.17  -0.28   0.02   0.05
  -0.30  -0.14   0.33   0.19   0.11   0.27  -0.03   0.02   0.17
  -0.21   0.27  -0.18  -0.03  -0.54   0.08   0.47   0.04   0.58
  -0.01   0.49   0.23   0.02   0.59  -0.39   0.29  -0.25   0.23
  -0.04   0.62   0.22   0.00  -0.07   0.11  -0.16   0.68  -0.23
  -0.03   0.45   0.14  -0.01  -0.30   0.28  -0.34  -0.68  -0.18
  
What format or command can I use to make Octave display matrices in this
way? (i.e. columns aligned on the decimal point using 2 decimal digits)
I'm using Octave version 3.6.4 on Ubuntu 13.04

Thanks,
AMG




--
View this message in context: 
http://octave.1599824.n4.nabble.com/Properly-formatting-matrices-in-Octave-tp4658820.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]