Contents
introduction
--- syntax
--- input
--- output
--- summary of options
arrays and tables
--- definitions
--- formatting
--- arrays
clear s;
s.r=reshape(1:4*6,[4,6]);
disp(s.r);
1 5 9 13 17 21
2 6 10 14 18 22
3 7 11 15 19 23
4 8 12 16 20 24
cprintf(s.r);
1 5 9 13 17 21
2 6 10 14 18 22
3 7 11 15 19 23
4 8 12 16 20 24
--- creating tables using row/column options
s.clab={'apple','orange','banana','kiwi','peach','pear','NOTUSED'};
s.rlab={'sweet','sour','salty','bitter'};
cprintf(s.r,...
'-Lc', s.clab);
apple orange banana kiwi peach pear
1 5 9 13 17 21
2 6 10 14 18 22
3 7 11 15 19 23
4 8 12 16 20 24
cprintf(s.r,...
'-Lr', s.rlab);
sweet 1 5 9 13 17 21
sour 2 6 10 14 18 22
salty 3 7 11 15 19 23
bitter 4 8 12 16 20 24
cprintf(s.r,...
'-Lr', s.rlab,...
'-Lc', s.clab,...
'-Lcs', '=');
apple orange banana kiwi peach pear
===============================================
sweet 1 5 9 13 17 21
sour 2 6 10 14 18 22
salty 3 7 11 15 19 23
bitter 4 8 12 16 20 24
cprintf(s.r,...
'-Lr', s.rlab,...
'-Lc', s.clab,...
'-Lrs', '|',...
'-Lcs', '=',...
'-Lh', {'A table'});
A table | apple orange banana kiwi peach pear
===================================================
sweet | 1 5 9 13 17 21
sour | 2 6 10 14 18 22
salty | 3 7 11 15 19 23
bitter | 4 8 12 16 20 24
cprintf(s.r,...
'-Lr', s.rlab,...
'-Lc', s.clab,...
'-Lrs', '|',...
'-Lcs', '=',...
'-la', 1);
| apple orange banana kiwi peach pear
==================================================
sweet | 1 5 9 13 17 21
sour | 2 6 10 14 18 22
salty | 3 7 11 15 19 23
bitter | 4 8 12 16 20 24
cprintf(s.r,...
'-Lr', s.rlab,...
'-Lc', s.clab,...
'-Lrs', '|',...
'-Lcs', '=',...
'-ic', 1);
| apple orange banana kiwi peach pear
============================================
sweet | 1 5 9 13 17 21
sour | 2 6 10 14 18 22
salty | 3 7 11 15 19 23
bitter | 4 8 12 16 20 24
cprintf(s.r,...
'-Lr', s.rlab,...
'-Lc', s.clab,...
'-Lrs', '|',...
'-Lcs', '=',...
'-d', '<.>');
<.>|<.> apple<.>orange<.>banana<.> kiwi<.> peach<.> pear
================================================================
sweet<.>|<.> 1<.> 5<.> 9<.> 13<.> 17<.> 21
sour<.>|<.> 2<.> 6<.> 10<.> 14<.> 18<.> 22
salty<.>|<.> 3<.> 7<.> 11<.> 15<.> 19<.> 23
bitter<.>|<.> 4<.> 8<.> 12<.> 16<.> 20<.> 24
cprintf(s.r,...
'-Lr', s.rlab,...
'-Lc', s.clab,...
'-Lrs', '#',...
'-Lcs', '=',...
'-dt', '|',...
'-d', '.');
.#. apple|orange|banana| kiwi| peach| pear
==================================================
sweet.#. 1| 5| 9| 13| 17| 21
sour.#. 2| 6| 10| 14| 18| 22
salty.#. 3| 7| 11| 15| 19| 23
bitter.#. 4| 8| 12| 16| 20| 24
cprintf(s.r,...
'-Lr', s.rlab,...
'-Lc', s.clab,...
'-Lrs', '|',...
'-Lcs', '=',...
'-dt', '|',...
'-d', '\t');
| apple|orange|banana| kiwi| peach| pear
====== = ======|======|======|======|======|======
sweet | 1| 5| 9| 13| 17| 21
sour | 2| 6| 10| 14| 18| 22
salty | 3| 7| 11| 15| 19| 23
bitter | 4| 8| 12| 16| 20| 24
s.cclab=s.clab;
s.rrlab=s.rlab;
s.cclab([1,2])={1,20};
s.rrlab([1,4])={pi,-4*pi};
s.cfmt='col:%d';
s.rfmt=@(x) sprintf('row:%d/%8.4f',sign(x),x);
cprintf(s.r,...
'-Lr', s.rrlab,...
'-Lc', s.cclab,...
'-Lrs', '|',...
'-Lcs', '=',...
'-nc', s.cfmt,...
'-nr', s.rfmt);
| col:1 col:20 banana kiwi peach pear
===========================================================
row:1/ 3.1416 | 1 5 9 13 17 21
sour | 2 6 10 14 18 22
salty | 3 7 11 15 19 23
row:-1/-12.5664 | 4 8 12 16 20 24
--- creating tables using the default format
cprintf(s.r,...
'-mt', 1);
| c:1 c:2 c:3 c:4 c:5 c:6
-----------------------------
r:1 | 1 5 9 13 17 21
r:2 | 2 6 10 14 18 22
r:3 | 3 7 11 15 19 23
r:4 | 4 8 12 16 20 24
cprintf(s.r,...
'-mt', 1,...
'-Lcs', '=',...
'-Lr', s.rlab,...
'-Lh', {'TBL.1'});
TBL.1 | c:1 c:2 c:3 c:4 c:5 c:6
================================
sweet | 1 5 9 13 17 21
sour | 2 6 10 14 18 22
salty | 3 7 11 15 19 23
bitter | 4 8 12 16 20 24
--- printing arrays that contain a predefined table
s.tbl={
'tbl', '|', 'C1','C2','C3','C4','C5','C6'
'=', '=', '=','-','=','sep','=','-'
'R1', 'sep', 1,2,3,4,5,6
'R2', '#', 1,2,3,4,5,6
};
disp(s.tbl);
cprintf(s.tbl);
'tbl' '|' 'C1' 'C2' 'C3' 'C4' 'C5' 'C6'
'=' '=' '=' '-' '=' 'sep' '=' '-'
'R1' 'sep' [ 1] [ 2] [ 3] [ 4] [ 5] [ 6]
'R2' '#' [ 1] [ 2] [ 3] [ 4] [ 5] [ 6]
tbl | C1 C2 C3 C4 C5 C6
= = = - = sep = -
R1 sep 1 2 3 4 5 6
R2 # 1 2 3 4 5 6
cprintf(s.tbl,...
'-it', 1);
tbl | C1 C2 C3 C4 C5 C6
===========----==== sep====----
R1 sep 1 2 3 4 5 6
R2 # 1 2 3 4 5 6
cprintf(s.tbl,...
'-it', 1,...
'-Lr', {'a','b'},...
'-Lcs', '*');
tbl | C1 C2 C3 C4 C5 C6
*************************
a sep 1 2 3 4 5 6
b # 1 2 3 4 5 6
--- leading and trailing text
cprintf(s.r,...
'-L', 'row\t');
row 1 5 9 13 17 21
row 2 6 10 14 18 22
row 3 7 11 15 19 23
row 4 8 12 16 20 24
cprintf(s.tbl,...
'-it', 1,...
'-L', 'my rows\t',...
'-T', '\teor');
my rows tbl | C1 C2 C3 C4 C5 C6 eor
my rows ===========----==== sep====---- eor
my rows R1 sep 1 2 3 4 5 6 eor
my rows R2 # 1 2 3 4 5 6 eor
CELL conversion options
--- 2D character arrays and ND cell arrays of ND character strings
s.sc=[
'this is a'
' test '
];
cprintf(s.sc,...
'-mt', 1,...
'-la', 1);
| c:1
---------------
r:1 | this is a
r:2 | test
s.cs={
'this is' 'yet another'
'test' ' example'
};
cprintf(s.cs,...
'-mt', 1);
| c:1 c:2
-----------------------------
r:1 | this is yet another
r:2 | test example
cprintf(s.cs,...
'-mt', 1,...
'-la', 1);
| c:1 c:2
-----------------------------
r:1 | this is yet another
r:2 | test example
s.ndcs={'foo','GOO'.';'HOO'.','ioo'};
disp(s.ndcs);
'foo' [3x1 char]
[3x1 char] 'ioo'
cprintf(s.ndcs,...
'-mt', 1,...
'-la', 1,...
'-d', '\t');
| c:1 c:2
--- - --- ---
r:1 | foo G
r:2 | O
r:3 | O
r:4 | H ioo
r:5 | O
r:6 | O
s.ndsc={
s.sc, [s.sc;s.sc;s.sc], s.sc
s.sc, 'FOO', [s.sc;s.sc]
'XXX'.', s.sc [s.sc;s.sc]
};
disp(s.ndsc);
[2x9 char] [6x9 char] [2x9 char]
[2x9 char] 'FOO' [4x9 char]
[3x1 char] [2x9 char] [4x9 char]
cprintf(s.ndsc,...
'-mt', 1,...
'-la', 1,...
'-d', ' ');
| c:1 c:2 c:3
--------------------------------------------
r:01 | this is a this is a this is a
r:02 | test test test
r:03 | this is a
r:04 | test
r:05 | this is a
r:06 | test
r:07 | this is a FOO this is a
r:08 | test test
r:09 | this is a
r:10 | test
r:11 | X this is a this is a
r:12 | X test test
r:13 | X this is a
r:14 | test
s.ndnd(:,:,1)=s.ndsc;
s.ndnd(:,:,2)=s.ndsc;
disp(s.ndnd);
(:,:,1) =
[2x9 char] [6x9 char] [2x9 char]
[2x9 char] 'FOO' [4x9 char]
[3x1 char] [2x9 char] [4x9 char]
(:,:,2) =
[2x9 char] [6x9 char] [2x9 char]
[2x9 char] 'FOO' [4x9 char]
[3x1 char] [2x9 char] [4x9 char]
cprintf(s.ndnd,...
'-mt', 1,...
'-dt', '|');
| c:1| c:2| c:3
------------------------------------
r:01 | this is a|this is a|this is a
r:02 | test | test | test
r:03 | |this is a|
r:04 | | test |
r:05 | |this is a|
r:06 | | test |
r:07 | this is a| FOO|this is a
r:08 | test | | test
r:09 | | |this is a
r:10 | | | test
r:11 | X|this is a|this is a
r:12 | X| test | test
r:13 | X| |this is a
r:14 | | | test
r:15 | this is a|this is a|this is a
r:16 | test | test | test
r:17 | |this is a|
r:18 | | test |
r:19 | |this is a|
r:20 | | test |
r:21 | this is a| FOO|this is a
r:22 | test | | test
r:23 | | |this is a
r:24 | | | test
r:25 | X|this is a|this is a
r:26 | X| test | test
r:27 | X| |this is a
r:28 | | | test
cprintf(s.ndnd,...
'-mt', 1,...
'-nex', 1);
| c:1 c:2 c:3
-----------------------------------------------
r:1 | O(2:2x9:char) O(2:6x9:char) O(2:2x9:char)
r:2 | O(2:2x9:char) FOO O(2:4x9:char)
r:3 | O(2:3x1:char) O(2:2x9:char) O(2:4x9:char)
r:4 | O(2:2x9:char) O(2:6x9:char) O(2:2x9:char)
r:5 | O(2:2x9:char) FOO O(2:4x9:char)
r:6 | O(2:3x1:char) O(2:2x9:char) O(2:4x9:char)
--- full mixed real and/or complex numeric arrays
s.m=[
1, 2, 3+3i
nan-4.2i, nan, inf
-inf, inf+3i*inf, inf+5.5i
];
disp(num2cell(s.m));
[ 1] [ 2] [ 3 + 3i]
[NaN - 4.2i] [ NaN] [ Inf]
[ -Inf] [NaN + Infi] [Inf + 5.5i]
cprintf(s.m,...
'-mt', 1);
| c:1 c:2 c:3
--------------------------------------
r:1 | 1 2 3 +3i
r:2 | NaN -4.2i NaN Inf
r:3 | -Inf NaN +Infi Inf +5.5i
cprintf(s.m,...
'-mt', 1,...
'-cla', 1);
| c:1 c:2 c:3
--------------------------------------
r:1 | 1 2 3 +3i
r:2 | NaN -4.2i NaN Inf
r:3 | -Inf NaN +Infi Inf +5.5i
cprintf(s.m,...
'-mt', 1,...
'-n', @(x) sprintf('%g=%s',x,num2hex(single(x))),...
'-cr', 'R %g',...
'-ci', 'I %+gi',...
'-cd', ' / ');
| c:1 c:2 c:3
-----------------------------------------------------------------------------
r:1 | 1=3f800000 / 2=40000000 / R 3 / I +3i
r:2 | R NaN / I -4.2i NaN=ffc00000 / Inf=7f800000 /
r:3 | -Inf=ff800000 / R NaN / I +Infi R Inf / I +5.5i
--- sparse mixed real and/or complex numeric arrays
s.s=sparse(4,4);
cprintf(s.s,...
'-mt', 1);
| c:1 c:2
-----------------
r:1 | (4 4) 0
s.s(1,1)=nan;
s.s(1,2)=inf;
s.s(1,3)=-inf;
s.s(1,4)=pi;
s.s(2,1)=4+3i;
s.s(2,2)=5+4i*inf;
s.s(2,3)=6+5i*nan;
disp(s.s);
(1,1) NaN
(2,1) 4 + 3i
(1,2) Inf
(2,2) NaN + Infi
(1,3) -Inf
(2,3) NaN + NaNi
(1,4) 3.1416
cprintf(s.s,...
'-mt', 1);
| c:1 c:2
---------------------------------
r:1 | (1 1) NaN
r:2 | (2 1) 4 +3i
r:3 | (1 2) Inf
r:4 | (2 2) NaN +Infi
r:5 | (1 3) -Inf
r:6 | (2 3) NaN NaNi
r:7 | (1 4) 3.14159
cprintf(s.s,...
'-mt', 1,...
'-ic', 1,...
'-n', ' value: %6.2f',...
'-cr', ' value: %6.2f',...
'-s', @(x,y) sprintf('R=%d C=%d',x,y));
| c:1 c:2
-------------------------------------
r:1 | R=1 C=1 value: NaN
r:2 | R=2 C=1 value: 4.00 +3i
r:3 | R=1 C=2 value: Inf
r:4 | R=2 C=2 value: NaN +Infi
r:5 | R=1 C=3 value: -Inf
r:6 | R=2 C=3 value: NaN NaNi
r:7 | R=1 C=4 value: 3.14
--- logical arrays
cprintf(real(s.m)>4,...
'-mt', 1);
| c:1 c:2 c:3
-----------------
r:1 | F F F
r:2 | F F T
r:3 | F F T
cprintf(imag(s.m)<1,...
'-mt', 1,...
'-f', 'NO',...
'-t', 'yes');
| c:1 c:2 c:3
-----------------
r:1 | yes yes NO
r:2 | yes yes yes
r:3 | yes NO NO
--- NaN/Inf
cprintf(s.m,...
'-mt', 1,...
'-d', '\t');
| c:1 c:2 c:3
--- - ---------- ---------- ----------
r:1 | 1 2 3 +3i
r:2 | NaN -4.2i NaN Inf
r:3 | -Inf NaN +Infi Inf +5.5i
cprintf(s.m,...
'-mt', 1,...
'-d', '\t',...
'-n', '%5.2f',...
'-N', '#fff#',...
'-I', @(x) sprintf('%dI',sign(x)),...
'-ci', '%5.2fi');
| c:1 c:2 c:3
--- - ------------ ------------ ------------
r:1 | 1.00 2.00 3 3.00i
r:2 | #fff# -4.20i #fff# 1I
r:3 | -1I #fff# 1I 1I 5.50i
--- hexadecimal representation of numeric input
cprintf(s.m,...
'-mt', 1,...
'-hs', 1);
| c:1 c:2 c:3
-----------------------------------------------------------
r:1 | 3f800000 40000000 40400000 40400000
r:2 | ffc00000 c0866666 ffc00000 7f800000
r:3 | ff800000 ffc00000 7f800000 7f800000 40b00000
cell arrays
s.ss=sparse(1,1,-pi);
s.cc={
'this', 'is', false, 2-3i, nan
'a cell', pi, 1000, s.ss, true
};
cprintf(s.cc,...
'-mt', 1);
| c:1 c:2 c:3 c:4 c:5
----------------------------------------------------------------------
r:1 | this is F 2 -3i NaN
r:2 | a cell 3.14159 1000 -3.14159 T
--- empty CELLs and other data types
cprintf([],...
'-Lr', {'empty array []'},...
'-mt', 1);
cprintf({[]},...
'-Lr', {'cell with empty array {[]}'},...
'-mt', 1);
cprintf({},...
'-Lr', {'empty cell {}'},...
'-mt', 1);
cprintf({{}},...
'-Lr', {'cell with empty cell {{}}'},...
'-mt', 1);
| c:1
--------------------------------------
empty array [] | E(double)
| c:1
--------------------------------------
cell with empty array {[]} | E(double)
| c:1
------------------------------------
empty cell {} | E(cell)
| c:1
-------------------------------------
cell with empty cell {{}} | C(2:0x0)
s.cc(1,1)={@(x) x};
s.cc(1,3)={[]};
s.cc(2,3)={sparse(3,3,-pi)};
s.cc(2,1)={repmat(struct('a','b'),[2,3,3])};
s.cc(3,1)={cell([3,3,3])};
s.cc(3,2)={s.cc};
s.cc(3,3)={repmat(struct('a',{'a'}),[2,2,3])};
disp(s.cc);
Columns 1 through 4
@(x)x 'is' [] [2 - 3i]
[2x3x3 struct] [ 3.1416] [3x3 double] [ -3.1416]
{3x3x3 cell } {3x5 cell} [2x2x3 struct] []
Column 5
[NaN]
[ 1]
[]
cprintf(s.cc,...
'-mt', 1);
| c:1 c:2 c:3 c:4 c:5
-------------------------------------------------------------------------------------
r:1 | F(@(x)x) is E(double) 2 -3i NaN
r:2 | S(3:2x3x3) 3.14159 N(2:3x3:double) -3.14159 T
r:3 | C(3:3x3x3) C(2:3x5) S(3:2x2x3) E(double) E(double)
s.O=@(x) sprintf('o:%d/%s',ndims(x),class(x));
cprintf(s.cc,...
'-mt', 1,...
'-E', 'empty',...
'-O', s.O);
| c:1 c:2 c:3 c:4 c:5
---------------------------------------------------------------------------------------------------------
r:1 | o:2/function_handle is empty 2 -3i NaN
r:2 | o:3/struct 3.14159 o:2/double -3.14159 T
r:3 | o:3/cell o:2/cell o:3/struct empty empty
--- surrounding text of CELLs
cprintf(s.m,...
'-mt', 1,...
'-C', '<%s>');
< > <|> <c:1> <c:2> <c:3>
------------------------------------------------
<r:1> <|> < 1 > < 2 > < 3 +3i>
<r:2> <|> < NaN -4.2i> < NaN > < Inf >
<r:3> <|> <-Inf > < NaN +Infi> < Inf +5.5i>
cprintf(s.m,...
'-mt', 1,...
'-Ct', '{%s\t}');
| c:1 c:2 c:3
--------------------------------------------------------------------
r:1 | { 1 } { 2 } { 3 +3i }
r:2 | { NaN -4.2i } { NaN } { Inf }
r:3 | {-Inf } { NaN +Infi } { Inf +5.5i }
ND arrays
s.nda=reshape(1:2*4*2*2*2,[2,4,2,2,2]);
disp(s.nda);
(:,:,1,1,1) =
1 3 5 7
2 4 6 8
(:,:,2,1,1) =
9 11 13 15
10 12 14 16
(:,:,1,2,1) =
17 19 21 23
18 20 22 24
(:,:,2,2,1) =
25 27 29 31
26 28 30 32
(:,:,1,1,2) =
33 35 37 39
34 36 38 40
(:,:,2,1,2) =
41 43 45 47
42 44 46 48
(:,:,1,2,2) =
49 51 53 55
50 52 54 56
(:,:,2,2,2) =
57 59 61 63
58 60 62 64
cprintf(s.nda,...
'-mt', 1);
| c:1 c:2 c:3 c:4
----------------------
r:01 | 1 3 5 7
r:02 | 2 4 6 8
r:03 | 9 11 13 15
r:04 | 10 12 14 16
r:05 | 17 19 21 23
r:06 | 18 20 22 24
r:07 | 25 27 29 31
r:08 | 26 28 30 32
r:09 | 33 35 37 39
r:10 | 34 36 38 40
r:11 | 41 43 45 47
r:12 | 42 44 46 48
r:13 | 49 51 53 55
r:14 | 50 52 54 56
r:15 | 57 59 61 63
r:16 | 58 60 62 64
ND cell arrays of mixed content
s.cmc=reshape(num2cell(1:2*2*2*2),[2,2,2,2]);
s.cmc(1,1,1,1)={magic(3)};
s.cmc(2,2,1,1)={s.ndcs};
s.cmc(1:2,1:2,2,1)=s.ndcs;
s.cmc(1,1,1,2)={'foo'};
s.cmc(1:2,2,1,2)={false,true};
s.cmc(1,1:2,2,2)={nan,-inf};
s.cmc(2,1:2,2,2)={-100-2i,100+2i};
disp(s.cmc);
(:,:,1,1) =
[3x3 double] [ 3]
[ 2] {2x2 cell}
(:,:,2,1) =
'foo' [3x1 char]
[3x1 char] 'ioo'
(:,:,1,2) =
'foo' [0]
[ 10] [1]
(:,:,2,2) =
[ NaN] [ -Inf]
[-100 - 2i] [100 + 2i]
cprintf(s.cmc,...
'-mt', 1,...
'-f', 'NO',...
'-t', 'YES',...
'-N', 'a nan',...
'-Ct', '<%s>',...
'-dt', ' | ',...
'-d', '\t');
| c:1 | c:2
---- - ----------------- | -----------------
r:01 | <N(2:3x3:double)> | < 3 >
r:02 | < 2 > | <C(2:2x2)>
r:03 | <foo> | <G>
r:04 | <> | <O>
r:05 | <> | <O>
r:06 | <H> | <ioo>
r:07 | <O> | <>
r:08 | <O> | <>
r:09 | <foo> | <NO>
r:10 | < 10 > | <YES>
r:11 | <a nan > | < -Inf >
r:12 | < -100 -2i> | < 100 +2i>
--- page indexing
cprintf(s.nda,...
'-mt', 1,...
'-nd', 1);
| c:1 c:2 c:3 c:4
----------------------------------------------------------------------
page | (1:2,1:4,1,1,1)
r:01 | 1 3 5 7
r:02 | 2 4 6 8
page | (1:2,1:4,2,1,1)
r:03 | 9 11 13 15
r:04 | 10 12 14 16
page | (1:2,1:4,1,2,1)
r:05 | 17 19 21 23
r:06 | 18 20 22 24
page | (1:2,1:4,2,2,1)
r:07 | 25 27 29 31
r:08 | 26 28 30 32
page | (1:2,1:4,1,1,2)
r:09 | 33 35 37 39
r:10 | 34 36 38 40
page | (1:2,1:4,2,1,2)
r:11 | 41 43 45 47
r:12 | 42 44 46 48
page | (1:2,1:4,1,2,2)
r:13 | 49 51 53 55
r:14 | 50 52 54 56
page | (1:2,1:4,2,2,2)
r:15 | 57 59 61 63
r:16 | 58 60 62 64
cprintf(s.cmc,...
'-mt', 1,...
'-nd', 1);
| c:1 c:2
--------------------------------------
page | (1:2,1:2,1,1)
r:01 | N(2:3x3:double) 3
r:02 | 2 C(2:2x2)
page | (1:2,1:2,2,1)
r:03 | foo G
r:04 | O
r:05 | O
r:06 | H ioo
r:07 | O
r:08 | O
page | (1:2,1:2,1,2)
r:09 | foo F
r:10 | 10 T
page | (1:2,1:2,2,2)
r:11 | NaN -Inf
r:12 | -100 -2i 100 +2i
ND structures
s.siz=[2,2,3,2];
s.fh=cprintf;
s.ns=num2cell(s.fh.comb(s.siz));
s.st=struct('a','','bb','','ccc','');
s.st=repmat(s.st,s.siz);
for ii=1:size(s.ns,1)
s.txt=sprintf('%d.',s.ns{ii,:});
s.txt(end)='';
s.st(s.ns{ii,:}).a=sprintf('%s-A',s.txt);
s.st(s.ns{ii,:}).bb=sprintf('%s-B',s.txt);
s.st(s.ns{ii,:}).ccc='XYZ'.';
end
clear ii;
disp(s.st);
disp('structure with indices (1,1,3,2)');
disp(s.st(1,1,3,2));
4-D struct array with fields:
a
bb
ccc
structure with indices (1,1,3,2)
a: '1.1.3.2-A'
bb: '1.1.3.2-B'
ccc: [3x1 char]
cprintf(s.st(1,1,3,2),...
'-mt', 1,...
'-Lc', {'fieldname','value'},...
'-dt', ' : ');
| fieldname : value
----------------------------
r:1 | a : 1.1.3.2-A
r:2 | bb : 1.1.3.2-B
r:3 | ccc : X
r:4 | : Y
r:5 | : Z
cprintf(s.st,...
'-mt', 1,...
'-nd', 1,...
'-nex', 1,...
'-dt', '|');
| c:1| c:2| c:3| c:4
--------------------------------------------------------------
page | (1:2,1:2,1,1)| | |
r:01 | a| 1.1.1.1-A| a| 1.2.1.1-A
r:02 | bb| 1.1.1.1-B| bb| 1.2.1.1-B
r:03 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
r:04 | a| 2.1.1.1-A| a| 2.2.1.1-A
r:05 | bb| 2.1.1.1-B| bb| 2.2.1.1-B
r:06 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
page | (1:2,1:2,2,1)| | |
r:07 | a| 1.1.2.1-A| a| 1.2.2.1-A
r:08 | bb| 1.1.2.1-B| bb| 1.2.2.1-B
r:09 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
r:10 | a| 2.1.2.1-A| a| 2.2.2.1-A
r:11 | bb| 2.1.2.1-B| bb| 2.2.2.1-B
r:12 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
page | (1:2,1:2,3,1)| | |
r:13 | a| 1.1.3.1-A| a| 1.2.3.1-A
r:14 | bb| 1.1.3.1-B| bb| 1.2.3.1-B
r:15 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
r:16 | a| 2.1.3.1-A| a| 2.2.3.1-A
r:17 | bb| 2.1.3.1-B| bb| 2.2.3.1-B
r:18 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
page | (1:2,1:2,1,2)| | |
r:19 | a| 1.1.1.2-A| a| 1.2.1.2-A
r:20 | bb| 1.1.1.2-B| bb| 1.2.1.2-B
r:21 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
r:22 | a| 2.1.1.2-A| a| 2.2.1.2-A
r:23 | bb| 2.1.1.2-B| bb| 2.2.1.2-B
r:24 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
page | (1:2,1:2,2,2)| | |
r:25 | a| 1.1.2.2-A| a| 1.2.2.2-A
r:26 | bb| 1.1.2.2-B| bb| 1.2.2.2-B
r:27 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
r:28 | a| 2.1.2.2-A| a| 2.2.2.2-A
r:29 | bb| 2.1.2.2-B| bb| 2.2.2.2-B
r:30 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
page | (1:2,1:2,3,2)| | |
r:31 | a| 1.1.3.2-A| a| 1.2.3.2-A
r:32 | bb| 1.1.3.2-B| bb| 1.2.3.2-B
r:33 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
r:34 | a| 2.1.3.2-A| a| 2.2.3.2-A
r:35 | bb| 2.1.3.2-B| bb| 2.2.3.2-B
r:36 | ccc|O(2:3x1:char)| ccc|O(2:3x1:char)
s.fh=figure('visible','off');
cprintf(struct(handle(line)),...
'-mt', 1,...
'-dt', ' : ');
delete(s.fh);
| c:1 : c:2
-------------------------------------------------------
r:01 | DisplayName :
r:02 | Annotation : O(2:1x1:hg.Annotation)
r:03 | Color : N(2:1x3:double)
r:04 | LineStyle : -
r:05 | LineWidth : 0.5
r:06 | Marker : none
r:07 | MarkerSize : 6
r:08 | MarkerEdgeColor : auto
r:09 | MarkerFaceColor : none
r:10 | XData : N(2:1x2:double)
r:11 | YData : N(2:1x2:double)
r:12 | ZData : E(double)
r:13 | BeingDeleted : off
r:14 | ButtonDownFcn : E(double)
r:15 | Children : E(double)
r:16 | Clipping : on
r:17 | CreateFcn : E(double)
r:18 | DeleteFcn : E(double)
r:19 | BusyAction : queue
r:20 | HandleVisibility : on
r:21 | HitTest : on
r:22 | Interruptible : on
r:23 | Selected : off
r:24 | SelectionHighlight : on
r:25 | Tag :
r:26 | Type : line
r:27 | UIContextMenu : E(double)
r:28 | UserData : E(double)
r:29 | Visible : on
r:30 | Parent : 171.001
--- anomalous structures
s.san=struct('a',{},'b',1);
s.san
clear ans;
cprintf(s.san,...
'-mt', 1,...
'-Lc', {'fieldname','value'},...
'-dt', ' : ');
ans =
0x0 struct array with fields:
a
b
| fieldname : value
----------------------------
r:1 | a : [?]
r:2 | b : [?]
ND arrays and ND cell arrays of other objects
if ispc
s.fh=figure('visible','off');
s.com=actxcontrol('mscal.Calendar',[20 20 300 300],s.fh);
s.fun=@(x) x+10;
s.O=@(x) sprintf('%s(%s )',class(x),sprintf(' %d',size(x)));
cprintf([s.com;s.com],...
'-mt', 1,...
'-O', s.O);
| c:1
-------------------------------
r:1 | COM.mscal_Calendar( 2 1 )
s.com={s.com,s.fun;s.fun,s.com};
cprintf(s.com,...
'-mt', 1);
| c:1 c:2
-------------------------------------------------------------
r:1 | O(2:1x1:COM.mscal_Calendar) F(@(x)x+10)
r:2 | F(@(x)x+10) O(2:1x1:COM.mscal_Calendar)
cprintf(s.com,...
'-mt', 1,...
'-O', s.O);
delete(s.fh);
| c:1 c:2
---------------------------------------------------------
r:1 | COM.mscal_Calendar( 1 1 ) function_handle( 1 1 )
r:2 | function_handle( 1 1 ) COM.mscal_Calendar( 1 1 )
end
output files
s.ftmpl='cptmpl.txt';
s.fout='cp_00X.00X';
type(s.ftmpl);
a test FO for CPRINTF file routines
FO : cptmpl.txt
created: <DATE>
-----------------------------------
% output $1
$MARK$
% output $2
$MARK$
--- creating output files
s.p=cprintf(s.m,...
'-mt', 1,...
'-fc', s.fout);
type(s.fout);
CP| create : 200 b cp_00X.00X
| c:1 c:2 c:3
--------------------------------------
r:1 | 1 2 3 +3i
r:2 | NaN -4.2i NaN Inf
r:3 | -Inf NaN +Infi Inf +5.5i
--- appending to files
s.p=cprintf(s.r,...
'-mt', 1,...
'-fa', s.fout,...
'-dt', '|');
type(s.fout);
delete(s.fout);
CP| append : 186 b cp_00X.00X
| c:1 c:2 c:3
--------------------------------------
r:1 | 1 2 3 +3i
r:2 | NaN -4.2i NaN Inf
r:3 | -Inf NaN +Infi Inf +5.5i
| c:1|c:2|c:3|c:4|c:5|c:6
-----------------------------
r:1 | 1| 5| 9| 13| 17| 21
r:2 | 2| 6| 10| 14| 18| 22
r:3 | 3| 7| 11| 15| 19| 23
r:4 | 4| 8| 12| 16| 20| 24
--- using a template file
type(s.ftmpl);
s.p=cprintf(s.m,...
'-mt', 1,...
'-fc', s.fout,...
'-fi', s.ftmpl,...
'-fm', '\$MARK\$');
type(s.fout);
a test FO for CPRINTF file routines
FO : cptmpl.txt
created: <DATE>
-----------------------------------
% output $1
$MARK$
% output $2
$MARK$
CP| template : cptmpl.txt
CP| create : 480 b cp_00X.00X
a test FO for CPRINTF file routines
FO : cptmpl.txt
created: <DATE>
-----------------------------------
% output $1
| c:1 c:2 c:3
--------------------------------------
r:1 | 1 2 3 +3i
r:2 | NaN -4.2i NaN Inf
r:3 | -Inf NaN +Infi Inf +5.5i
% output $2
$MARK$
s.p=cprintf(s.r,...
'-mt', 1,...
'-dt', '|',...
'-fc', s.fout,...
'-fi', s.fout,...
'-fm', '\$MARK\$');
type(s.fout);
delete(s.fout);
CP| template : cp_00X.00X
CP| create : 680 b cp_00X.00X
a test FO for CPRINTF file routines
FO : cptmpl.txt
created: <DATE>
-----------------------------------
% output $1
| c:1 c:2 c:3
--------------------------------------
r:1 | 1 2 3 +3i
r:2 | NaN -4.2i NaN Inf
r:3 | -Inf NaN +Infi Inf +5.5i
% output $2
| c:1|c:2|c:3|c:4|c:5|c:6
-----------------------------
r:1 | 1| 5| 9| 13| 17| 21
r:2 | 2| 6| 10| 14| 18| 22
r:3 | 3| 7| 11| 15| 19| 23
r:4 | 4| 8| 12| 16| 20| 24
--- replacing tokens in template files
s.tok={
'FO', 'file'
'<DATE>', datestr(clock)
'output \$', 'result #'
};
s.p=cprintf(s.r,...
'-mt', 1,...
'-dt', '|',...
'-fc', s.fout,...
'-fi', s.ftmpl,...
'-fr', s.tok,...
'-fm', '\$MARK\$');
s.p=cprintf(s.m,...
'-mt', 1,...
'-dt', '|',...
'-fa', s.fout,...
'-fi', s.fout,...
'-fr', s.tok,...
'-fm', '\$MARK\$');
type(s.fout);
delete(s.fout);
CP| template : cptmpl.txt
CP| create : 507 b cp_00X.00X
CP| template : cp_00X.00X
CP| create : 680 b cp_00X.00X
a test file for CPRINTF file routines
file : cptmpl.txt
created: 11-Jun-2009 08:59:04
-----------------------------------
% result #1
| c:1|c:2|c:3|c:4|c:5|c:6
-----------------------------
r:1 | 1| 5| 9| 13| 17| 21
r:2 | 2| 6| 10| 14| 18| 22
r:3 | 3| 7| 11| 15| 19| 23
r:4 | 4| 8| 12| 16| 20| 24
% result #2
| c:1| c:2| c:3
--------------------------------------
r:1 | 1 | 2 | 3 +3i
r:2 | NaN -4.2i| NaN | Inf
r:3 | -Inf | NaN +Infi| Inf +5.5i
option processing
--- option precedence
--- option preferences across MATLAB sessions
s.opref=getpref('cprintf');
setpref('cprintf','opt',{'-mt',1});
cprintf(s.r);
| c:1 c:2 c:3 c:4 c:5 c:6
-----------------------------
r:1 | 1 5 9 13 17 21
r:2 | 2 6 10 14 18 22
r:3 | 3 7 11 15 19 23
r:4 | 4 8 12 16 20 24
cprintf(s.r,...
'-p',...
'-d', ' | ');
1 | 5 | 9 | 13 | 17 | 21
2 | 6 | 10 | 14 | 18 | 22
3 | 7 | 11 | 15 | 19 | 23
4 | 8 | 12 | 16 | 20 | 24
cprintf(s.r,...
'-mt', 0,...
'-d', ' | ');
if ~isempty(s.opref)
setpref('cprintf','opt',s.opref.opt);
else
rmpref('cprintf');
end
1 | 5 | 9 | 13 | 17 | 21
2 | 6 | 10 | 14 | 18 | 22
3 | 7 | 11 | 15 | 19 | 23
4 | 8 | 12 | 16 | 20 | 24
--- reading and writing option files
s.fini='cpini.txt';
s.fout=sprintf('cpini_%s',num2hex(rand(1,2)));
type(s.fini);
CPINIT.TXT a cprintf ini file example
created:
us 10-Jan-2008 us@neurol.unizh.ch
modified:
us 11-Jun-2009 08:58:55
localid: us@USZ|ws-nos-36362|x86|Windows XP|7.7.0.471.R2008b
--------------------------------------------------------------------------------
,, , ;
note nonsense options FOO_xx
decoding starts after FIRST occurrence of a typical option pair:
'-begin','start of options'; % an option comment
'-FOO_x1',{
1 2 3 % a cell comment
3 2 1
};
% a line comment
'-mt',1,'-nd',pi
'-Lcs','=',
'-Lr' , , , , ,num2cell(--5:-10*-1);
,,,'-Lc' , {'X','Y'}.'
'-FOO_x2',{{'abc',1,'12'},'foo',--12:--23}
'-FOO_x3',rand(2,2,3)
'-FOO_x4',,,,'-FOO_x5','-E',@(x) sprintf('%s',class(x));;'-t','+';,;,,;
'-FOO_x6'={
1 2 3
3 2 1
};'-FOO_x7',{1,2,3;4,5,6};,,'-FOO_x8','-',;;
'-tab',10,,,'-f','-',,,,,
'-FOO_x8','foo' ; ,;
cprintf(bitand(s.r,1)~=0,...
'-mt', 1,...
'-ini', s.fini,...
'-sav', s.fout);
CP| file : F:\usr\matlab\tmp\fex\acprint\cpini.txt
CP| create : cpini_33ffee8977f214d71100324575201d4a
CP| options : 18 unique/user defined
| X Y X Y X Y
=================
r:5 | + + + + + +
r:6 | - - - - - -
r:7 | + + + + + +
r:8 | - - - - - -
disp('***** FILE CONTENT');
type(s.fout);
***** FILE CONTENT
%CPRINTF option file cpini_33ffee8977f214d71100324575201d4a.m
%version 11-Jun-2009 08:58:55
%created 11-Jun-2009 08:59:04
%options 18 unique/user defined
%
%SYNTAX opt = cpini_33ffee8977f214d71100324575201d4a.m;
%--------------------------------------------------------------------
function o = cpini_33ffee8977f214d71100324575201d4a(varargin)
%%% section ----------- CPRINTF ---------- user data
o. magic = 'CPRINTF';
o. ver = '11-Jun-2009 08:58:55';
o. MLver = '7.8.0.347 (R2009a)';
o. begin = 'start of options';% an option comment;
o.FOO_x1 = {
1 2 3 % a cell comment
3 2 1
};% a line comment;
o. mt = 1;
o. nd = pi;
o. Lcs = '=';
o. Lr = num2cell(--5:-10*-1);
o. Lc = {'X','Y'}.';
o.FOO_x2 = {{'abc',1,'12'},'foo',--12:--23};
o.FOO_x3 = rand(2,2,3);
o.FOO_x4 = [];
o.FOO_x5 = [];
o. E = @(x) sprintf('%s',class(x));
o. t = '+';
o.FOO_x6 = {
1 2 3
3 2 1
};
o.FOO_x7 = {1,2,3;4,5,6};
o.FOO_x8 = '-';
o. tab = 10;
o. f = '-';
o.FOO_x8 = 'foo';
%%% section ----------- CPRINTF ---------- user data
end
disp('***** HELP SECTION');
help(s.fout);
***** HELP SECTION
CPRINTF option file cpini_33ffee8977f214d71100324575201d4a.m
version 11-Jun-2009 08:58:55
created 11-Jun-2009 08:59:04
options 18 unique/user defined
SYNTAX opt = cpini_33ffee8977f214d71100324575201d4a.m;
--------------------------------------------------------------------
disp('***** OPTION STRUCTURE');
s.val=feval(s.fout);
disp(s.val);
***** OPTION STRUCTURE
magic: 'CPRINTF'
ver: '11-Jun-2009 08:58:55'
MLver: '7.8.0.347 (R2009a)'
begin: 'start of options'
FOO_x1: {2x3 cell}
mt: 1
nd: 3.1416
Lcs: '='
Lr: {[5] [6] [7] [8] [9] [10]}
Lc: {2x1 cell}
FOO_x2: {{1x3 cell} 'foo' [12 13 14 15 16 17 18 19 20 21 22 23]}
FOO_x3: [2x2x3 double]
FOO_x4: []
FOO_x5: []
E: @(x)sprintf('%s',class(x))
t: '+'
FOO_x6: {2x3 cell}
FOO_x7: {2x3 cell}
FOO_x8: 'foo'
tab: 10
f: '-'
--- option structures
s.sopt.a='a';
s.sopt.Lc={1,'XYZ',2};
s.sopt.Lcs='=';
s.sopt.Lr=s.rlab;
cprintf(s.r,...
'-mt', 1,...
'-opt', s.sopt);
| c:1 XYZ c:2 c:1 XYZ c:2
================================
sweet | 1 5 9 13 17 21
sour | 2 6 10 14 18 22
salty | 3 7 11 15 19 23
bitter | 4 8 12 16 20 24
cprintf(s.r>12,...
'-mt', 1,...
'-opt', feval(s.fout));
delete([s.fout,'.m']);
| X Y X Y X Y
=================
r:5 | - - - + + +
r:6 | - - - + + +
r:7 | - - - + + +
r:8 | - - - + + +
engine options
--- TAB size and TAB replacement in CELLs
cprintf(s.m,...
'-mt', 1,...
'-Ct', '{%s\t}',...
'-tab', 2);
| c:1 c:2 c:3
--------------------------------------------------
r:1 | { 1 } { 2 } { 3 +3i }
r:2 | { NaN -4.2i } { NaN } { Inf }
r:3 | {-Inf } { NaN +Infi } { Inf +5.5i }
s.stab={sprintf('a\t\t\ttab'),sprintf('b\t\ttab'),'c d';100,200,300};
cprintf(s.stab,...
'-mt', 1);
| c:1 c:2 c:3
--------------------------------------------------------------------------------------------
r:1 | a tab b tab c d
r:2 | 100 200 300
s.res=cprintf(s.stab,...
'-mt', 1,...
'-ntab',1);
s.rres=strrep(cellstr(s.res),sprintf('\t'),'.');
disp(sprintf('\noriginal output\n'));
disp(s.res);
disp(sprintf('\noriginal output with later TAB replacements\n'));
disp(char(s.rres));
original output
| c:1 c:2 c:3
-----------------------------
r:1 | a tab b tab c d
r:2 | 100 200 300
original output with later TAB replacements
| c:1 c:2 c:3
-----------------------------
r:1 | a...tab b..tab c d
r:2 | 100 200 300
--- runtime printout
cprintf(s.m,...
'-mt', 1,...
'-db', 1);
CP| --------- :
CP| format : 9 c
CP| type : empty = 9 c
CP| type : empty = - 0 c 0.000000 sec
CP| type : logical = 9 c
CP| type : logical = - 0 c 0.000000 sec
CP| type : numeric = 9 c
CP| type : numeric = - 13 c 0.000000 sec
CP| format : done = 0 c 0.000000 sec
CP| print : 25 c
CP| print : done = 0.000000 sec
CP| --------- : done = 0.000000 sec
----------------------------------------------------
| c:1 c:2 c:3
--------------------------------------
r:1 | 1 2 3 +3i
r:2 | NaN -4.2i NaN Inf
r:3 | -Inf NaN +Infi Inf +5.5i
output
--- macros
s.mac=cprintf;
s.opt=s.mac.getpar('-foo','goo','-Lc',{'a',1,'b'},'-mt',0,'-nd',[]);
disp(s.opt);
Lc: {'a' [1] 'b'}
mt: 0
s.opt=s.mac.setpar(s.val);
disp(s.opt);
E: @(x)sprintf('%s',class(x))
Lc: {2x1 cell}
Lcs: '='
Lr: {[5] [6] [7] [8] [9] [10]}
f: '-'
mt: 1
nd: 3.1416
t: '+'
tab: 10
s.opt=s.mac.ini(s.fini);
disp(s.opt);
CP| file : F:\usr\matlab\tmp\fex\acprint\cpini.txt
CP| create : temporary file removed
CP| options : 18 unique/user defined
magic: 'CPRINTF'
ver: '11-Jun-2009 08:58:55'
MLver: '7.8.0.347 (R2009a)'
begin: 'start of options'
FOO_x1: {2x3 cell}
mt: 1
nd: 3.1416
Lcs: '='
Lr: {[5] [6] [7] [8] [9] [10]}
Lc: {2x1 cell}
FOO_x2: {{1x3 cell} 'foo' [12 13 14 15 16 17 18 19 20 21 22 23]}
FOO_x3: [2x2x3 double]
FOO_x4: []
FOO_x5: []
E: @(x)sprintf('%s',class(x))
t: '+'
FOO_x6: {2x3 cell}
FOO_x7: {2x3 cell}
FOO_x8: 'foo'
tab: 10
f: '-'
s.fwrite='CP_00X.00X';
s.mac.write(s.r,'-fc',s.fwrite);
type(s.fwrite);
delete(s.fwrite);
1 5 9 13 17 21
2 6 10 14 18 22
3 7 11 15 19 23
4 8 12 16 20 24
s.oval={pi,magic(3)+1i,cell(2,2),sparse(2,2,3+1i),@(x) x+10};
s.oval=s.mac.other(s.oval{:});
disp(s.oval);
'N(2:1x1:double)'
'N(2:3x3:double.c)'
'C(2:2x2)'
'N(2:2x2:double.s.c)'
'F(@(x)x+10)'
s.pix=s.mac.comb(size(rand([2,2,1,2])));
disp(s.pix);
1 1 1 1
2 1 1 1
1 2 1 1
2 2 1 1
1 1 1 2
2 1 1 2
1 2 1 2
2 2 1 2
--- arguments
s.p=cprintf;
[s.rs,s.rc,s.mc,s.par]=cprintf(s.m,...
'-mt', 1);
disp(s.rs);
| c:1 c:2 c:3
--------------------------------------
r:1 | 1 2 3 +3i
r:2 | NaN -4.2i NaN Inf
r:3 | -Inf NaN +Infi Inf +5.5i
disp(s.mc);
[ 1] [ 2] [ 3 + 3i]
[NaN - 4.2i] [ NaN] [ Inf]
[ -Inf] [NaN + Infi] [Inf + 5.5i]
disp(s.rc);
' ' '|' 'c:1' 'c:2' 'c:3'
'-' '-' '-' '-' '-'
'r:1' '|' ' 1 ' ' 2 ' ' 3 +3i'
'r:2' '|' ' NaN -4.2i' ' NaN ' ' Inf '
'r:3' '|' '-Inf ' ' NaN +Infi' ' Inf +5.5i'
s.p=cprintf(s.m,...
'-mt', 1,...
'-so', 1);
disp(s.p);
magic: 'CPRINTF'
ver: '11-Jun-2009 08:58:55'
MLver: '7.8.0.347 (R2009a)'
section_10: '---------- INPUT ------------'
arg: [3x3 double]
class: 'double'
isnumeric: 1
section_20: '---------- OPTIONS ------------'
otbl: {53x2 cell}
hasotbl: [53x1 logical]
opt: [1x1 struct]
hasopt: [1x1 struct]
islog: {17x1 cell}
section_30: '---------- ENGINE ------------'
fpar: {6x6 cell}
ctbl: {5x5 cell}
ndc: 2
nsc: [3 3]
nnc: 9
pr: 5
pc: 5
in: [25x1 logical]
sconv: 13
type: [1x1 struct]
istbl: 1
hastbl: [2 2]
tlabel: [-1 -2 -1 -2]
tbody: [3 5 3 5]
sepr: {3x1 cell}
sepc: {'-' '-' '-' '-' '-'}
fmt: '%3.3s %1.1s %10.10s %10.10s %10.10s'
fmts: [3 1 10 10 10]
dels: 1
delst: 1
tabc: ' '
tabs: ' '
nmod: 1
section_31: '---------- macros -----------'
getpar: @(varargin)CPRINTF_parse_option(0,varargin{:})
setpar: @(varargin)CPRINTF_struct2opt(0,varargin{:})
ini: @(varargin)CPRINTF_ini2opt(0,varargin{:})
write: @(varargin)CPRINTF_ascii2file(varargin{:})
other: @CPRINTF_other
comb: @(varargin)CPRINTF_comb([varargin{:}])
disp: @CPRINTF_nodisp
s2f: @str2func
section_40: '---------- OUTPUT ------------'
text: [5x38 char]
cell: {5x5 cell}
carg: {3x3 cell}
disp(s.p.cell);
' ' '|' 'c:1' 'c:2' 'c:3'
'-' '-' '-' '-' '-'
'r:1' '|' ' 1 ' ' 2 ' ' 3 +3i'
'r:2' '|' ' NaN -4.2i' ' NaN ' ' Inf '
'r:3' '|' '-Inf ' ' NaN +Infi' ' Inf +5.5i'
--- input to xlswrite