![]() |
KerMor
0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
|
PrintTable: Class that allows table-like output spaced by tabs for multiple rows. More...
PrintTable: Class that allows table-like output spaced by tabs for multiple rows.
Allows to create a table-like output for multiple values and columns. A spacer can be used to distinguish different columns (PrintTable.ColSep) and a flag (PrintTable.HasHeader) can be set to insert a line of dashes after the first row. The table can be printed directly to the console or be written to a file.
plain
, which means simple output as formatted string. If set to tex
, the table is printed in a LaTeX table environment (PrintTable.ColSep is ignored and &
used automatically).When passing a function handle, it may also take two arguments. The second argument is then used to pass in the column number which is currently formatted.
arraystretch
)This class has originally been developed as part of the framework
Homepage
http://www.morepas.org/software/index.htmlDocumentation
http://www.morepas.org/software/kermor/index.htmlCopyright (c) 2011, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted only in compliance with the BSD license, see http://www.opensource.org/licenses/bsd-license.php
Definition at line 17 of file PrintTable.m.
Public Member Functions | |
PrintTable (char caption,cell varargin) | |
Creates a new PrintTable instance. More... | |
function | display () |
Overload for the default builtin display method. More... | |
function | print (integer outfile) |
Prints the current table to a file pointer. More... | |
function char str = | toString () |
Returns a character array representation of the current table. More... | |
function | saveToFile (char filename,logical openfile) |
Prints the current table to a file. More... | |
function | addMatrix (titles, data, varargin) |
function | addRow (varargin) |
Adds a row to the current table. More... | |
function | clear () |
Clears the current PrintTable contents and caption. More... | |
function | removeRow (integer idx) |
Removes a row from the PrintTable. More... | |
function this = | sort (integer colnr,char direction) |
Sorts this table in alphanumeric order. More... | |
function
transposed = | ctranspose () |
function copy = | clone () |
Returns a new instance of PrintTable with the same content. More... | |
function joined = | append (PrintTable table,rowvec< integer > columns) |
Appends the cell contents from another table to this table. More... | |
Static Public Member Functions | |
static function [ res , double t ] = | test_PrintTable () |
A simple test for PrintTable. More... | |
static function [ res , double t ] = | test_PrintTable_Misc () |
A simple test for PrintTable. More... | |
static function [ res , double t ] = | test_PrintTable_LaTeX_Export () |
A simple test for PrintTable. More... | |
static function [ res , double t ] = | test_PrintTable_Failed_LaTeX_Export () |
Public Attributes | |
integer | TabCharLen = PrintTable.getDefaultTabCharLen |
Equivalent length of a tab character in single-space characters. More... | |
char | ColSep = " | " |
A char sequence to separate the different columns. More... | |
logical | HasHeader = false |
Flag that determines if the first row should be used as table header. More... | |
logical | HasRowHeader = false |
Flag that determines if there is a row header for the table. More... | |
enum | Format = "txt" |
The output format of the table when using the print method. More... | |
char | Caption = "" |
A caption for the table. More... | |
logical | TightPDF = true |
Flag that indicates if exported tables in PDF format should be sized to the actual table size or be contained in a normal unformatted article page. More... | |
logical | StripInsertedTabChars = true |
Flag that determines if inserted tab characters are stripped from any string to preserve the correct display of the PrintTable. More... | |
integer | NumRows |
The number of rows in the current table. More... | |
logical | TexMathModeDetection |
Flag that tells the PrintTable to surround numerical values with dollar signs "$$" to obtain a more suitable LaTeX number representation. More... | |
data | |
The string cell data. More... | |
mathmode | |
Flag matrix to indicate if a cell value is numeric or not. More... | |
contlen | |
Maximum content length for each colummn. More... | |
haslatexcommand = false | |
Flag to maximize user convenience; this is set whenever a row adding resulted in a string containing a backslash, indicating that latex commands are used. If so, a warning is issued on tex export if TexMathModeDetection is switched off. More... | |
![]() | |
addlistener | |
Creates a listener for the specified event and assigns a callback function to execute when the event occurs. More... | |
notify | |
Broadcast a notice that a specific event is occurring on a specified handle object or array of handle objects. More... | |
delete | |
Handle object destructor method that is called when the object's lifecycle ends. More... | |
disp | |
Handle object disp method which is called by the display method. See the MATLAB disp function. More... | |
display | |
Handle object display method called when MATLAB software interprets an expression returning a handle object that is not terminated by a semicolon. See the MATLAB display function. More... | |
findobj | |
Finds objects matching the specified conditions from the input array of handle objects. More... | |
findprop | |
Returns a meta.property objects associated with the specified property name. More... | |
fields | |
Returns a cell array of string containing the names of public properties. More... | |
fieldnames | |
Returns a cell array of string containing the names of public properties. See the MATLAB fieldnames function. More... | |
isvalid | |
Returns a logical array in which elements are true if the corresponding elements in the input array are valid handles. This method is Sealed so you cannot override it in a handle subclass. More... | |
eq | |
Relational functions example. See details for more information. More... | |
transpose | |
Transposes the elements of the handle object array. More... | |
permute | |
Rearranges the dimensions of the handle object array. See the MATLAB permute function. More... | |
reshape | |
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape function. More... | |
sort | |
ort the handle objects in any array in ascending or descending order. More... | |
Creates a new PrintTable instance.
caption | The caption of the table. Default: ' |
varargin | If given, they will be passed to sprintf using the specified caption argument to create the table's Caption. Default: [] |
Definition at line 447 of file PrintTable.m.
References Caption, and clear().
Referenced by clone().
function PrintTable.addMatrix | ( | titles, | |
data, | |||
varargin | |||
) |
Definition at line 603 of file PrintTable.m.
References addRow(), data, and k.
function PrintTable.addRow | ( | varargin | ) |
Adds a row to the current table.
varargin | Any number of arguments >= 1, each corresponding to a column of the table. Each argument must be a char array. |
Definition at line 611 of file PrintTable.m.
References contlen, data, haslatexcommand, and mathmode.
Referenced by addMatrix(), and testing.Speed.BinaryvsMatSave().
function joined = PrintTable.append | ( | PrintTable | table, |
rowvec< integer > | columns | ||
) |
Appends the cell contents from another table to this table.
table | The other table |
columns | The column indices to transfer. Default: all |
Definition at line 778 of file PrintTable.m.
References Caption, clone(), contlen, data, HasHeader, haslatexcommand, k, mathmode, and NumRows.
function PrintTable.clear | ( | ) |
Clears the current PrintTable contents and caption.
Definition at line 654 of file PrintTable.m.
References Caption, contlen, and data.
Referenced by PrintTable().
function copy = PrintTable.clone | ( | ) |
Returns a new instance of PrintTable with the same content.
Definition at line 755 of file PrintTable.m.
References Caption, ColSep, contlen, data, Format, HasHeader, haslatexcommand, HasRowHeader, mathmode, PrintTable(), StripInsertedTabChars, and TightPDF.
Referenced by append(), and ctranspose().
function transposed = PrintTable.ctranspose | ( | ) |
Definition at line 740 of file PrintTable.m.
References clone(), data, k, mathmode, handle.reshape, and t.
function PrintTable.display | ( | ) |
Overload for the default builtin display method.
Calls print with argument 1, i.e. standard output.
Definition at line 468 of file PrintTable.m.
References print().
function PrintTable.print | ( | integer | outfile | ) |
Prints the current table to a file pointer.
outfile | The file pointer to print to. Must either be a valid MatLab fileID or can be 1 or 2, for stdout or stderr, respectively. Default: 1 |
Definition at line 481 of file PrintTable.m.
References t.
Referenced by display(), saveToFile(), and toString().
function PrintTable.removeRow | ( | integer | idx | ) |
Removes a row from the PrintTable.
idx | The index of the row to remove |
Definition at line 665 of file PrintTable.m.
References data.
Prints the current table to a file.
If a file name is specified, the format is determined by the file extension. Allowed types are "txt" for plain text, "tex" for a LaTeX table and "pdf" for an immediate export of the LaTeX table to a PDF document.
filename | The file to print to. If the file exists, any contents are discarded. If the file does not exist, an attempt to create a new one is made. Default: Prompts for saving target |
openfile | Flag that indicates if the exported file should be opened after saving. Default: false |
Definition at line 522 of file PrintTable.m.
References Caption, Format, and print().
Sorts this table in alphanumeric order.
Optionally, a column number and sort direction can be specified.
The default sort column is one. If you set HasHeader to true, the default sort column will be two. However, the column numbering will always include the first column in order to explicitly allow sorting by row headers.
colnr | The column number Default: 1 or 2 depending on HasHeader setting |
direction | The sort direction ascend or descend Default: ascend |
Definition at line 680 of file PrintTable.m.
Definition at line 1427 of file PrintTable.m.
function char str = PrintTable.toString | ( | ) |
Returns a character array representation of the current table.
str | The table as string |
Definition at line 507 of file PrintTable.m.
References print().
PrintTable.Caption = "" |
A caption for the table.
Depending on the output the caption is added: plain: First line above table tex: Inserted into the \caption command
Default: '
Definition at line 316 of file PrintTable.m.
Referenced by append(), clear(), clone(), data.ApproxTrainData.getErrorsFor(), PrintTable(), and saveToFile().
PrintTable.ColSep = " | " |
A char sequence to separate the different columns.
Default: |
Definition at line 256 of file PrintTable.m.
Referenced by clone().
PrintTable.contlen |
Maximum content length for each colummn.
SetAccess = Private, GetAccess = Public
Definition at line 414 of file PrintTable.m.
PrintTable.data |
The string cell data.
SetAccess = Private, GetAccess = Public
Definition at line 388 of file PrintTable.m.
Referenced by addMatrix(), addRow(), append(), clear(), clone(), ctranspose(), removeRow(), and sort().
PrintTable.Format = "txt" |
The output format of the table when using the print method.
Hide
the valid format pdf as its only used internally .. i know .. lazyness :-)
Currently the values txt
for plaintext and tex
for LaTeX output are available.
Default: txt
Definition at line 303 of file PrintTable.m.
Referenced by clone(), and saveToFile().
PrintTable.HasHeader = false |
Flag that determines if the first row should be used as table header.
If true, a separate line with dashes will be inserted after the first printed row.
Default: false
Definition at line 266 of file PrintTable.m.
Referenced by append(), clone(), sort(), and testing.Speed.TryCatch().
PrintTable.haslatexcommand = false |
Flag to maximize user convenience; this is set whenever a row adding resulted in a string containing a backslash, indicating that latex commands are used. If so, a warning is issued on tex export if TexMathModeDetection is switched off.
SetAccess = Private, GetAccess = Public
Definition at line 425 of file PrintTable.m.
PrintTable.HasRowHeader = false |
Flag that determines if there is a row header for the table.
If true, this causes a special behaviour regarding formatting the the first argument passed to PrintTable.addRow. Let \(n\) be the total number of row content arguments.
f
}, is given: This format will be applied to all but the first argument of addRow. This is the actual reason why this flag was introduced, in order to be able to specify a current row string header and set the format for all other entries using one format string.A cell with \(n\) format strings is given: They will be applied to all content arguments including the row header (in that order)
Default: false
Definition at line 278 of file PrintTable.m.
Referenced by clone(), and models.BaseFirstOrderSystem.getParamInfo().
PrintTable.mathmode |
Flag matrix to indicate if a cell value is numeric or not.
Used for TeX output.
SetAccess = Private, GetAccess = Public
Definition at line 399 of file PrintTable.m.
Referenced by addRow(), append(), clone(), ctranspose(), and sort().
PrintTable.NumRows |
The number of rows in the current table.
Dependent
set to true. Definition at line 357 of file PrintTable.m.
Referenced by append().
PrintTable.StripInsertedTabChars = true |
Flag that determines if inserted tab characters are stripped from any string to preserve the correct display of the PrintTable.
Affects both directly set strings and those produced by providing a format pattern.
Default: true
Definition at line 342 of file PrintTable.m.
Referenced by clone().
PrintTable.TabCharLen = PrintTable.getDefaultTabCharLen |
Equivalent length of a tab character in single-space characters.
Default: PrintTable.DefaultTabCharLen
Definition at line 244 of file PrintTable.m.
PrintTable.TexMathModeDetection |
Flag that tells the PrintTable to surround numerical values with dollar signs "$$" to obtain a more suitable LaTeX number representation.
Set to false to produce plain output of cell contents "as they are".
Default: true
Dependent
set to true. Definition at line 370 of file PrintTable.m.
PrintTable.TightPDF = true |
Flag that indicates if exported tables in PDF format should be sized to the actual table size or be contained in a normal unformatted article page.
Default: true
Definition at line 330 of file PrintTable.m.
Referenced by clone().