octave-maintainers
[Top][All Lists]
Advanced

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

Re: displaying structures array as table


From: CdeMills
Subject: Re: displaying structures array as table
Date: Tue, 30 Aug 2011 07:21:24 -0700 (PDT)

Hello Jordi,

an educated guess is that the row names should have more or less the same
width. Let's say that the maximum width is 8, then a possible implementation
is

a=[]; a(1).a = 1; a(2).a=2;a(1).b=3;a(2).b=4; 
for indi = (fieldnames(a)).'
  printf ('%2s %s', indi{:}, disp ([a.(indi{:})]));
end

results in         
 a    1.0000e+00   2.0000e+00
 b    3.0000e+00   4.0000e+00

The trick is to call 'disp' to generate the last string, which ensures it is
terminated by a line feed.
This way, the call to disp is encapsulated, so basically the format used is
the default one. The only thing to be adjusted is the width of the row
names.

Regards

Pascal



--
View this message in context: 
http://octave.1599824.n4.nabble.com/displaying-structures-array-as-table-tp3778402p3778832.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.


reply via email to

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