Format real, complex, and logical matrices as strings.
The returned string may be used to reconstruct the original matrix by using
the eval
function.
The precision of the values is given by n. If n is a scalar
then both real and imaginary parts of the matrix are printed to the same
precision. Otherwise n(1)
defines the precision of the real
part and n(2)
defines the precision of the imaginary part.
The default for n is 15.
If the argument "class"
is given then the class of x is
included in the string in such a way that eval
will result in the
construction of a matrix of the same class.
mat2str ([ -1/3 + i/7; 1/3 - i/7 ], [4 2]) ⇒ "[-0.3333+0.14i;0.3333-0.14i]" mat2str ([ -1/3 +i/7; 1/3 -i/7 ], [4 2]) ⇒ "[-0.3333+0i 0+0.14i;0.3333+0i -0-0.14i]" mat2str (int16 ([1 -1]), "class") ⇒ "int16([1 -1])" mat2str (logical (eye (2))) ⇒ "[true false;false true]" isequal (x, eval (mat2str (x))) ⇒ 1
See also: sprintf, num2str, int2str.
Package: octave