mat2str

Writes the values of a 2D matrix, m, to a string, R.

Syntax

R = mat2str(m)

R = mat2str(m, p)

R = mat2str(m, p, 'class')

Inputs

m
2D Matrix.
Type: matrix
p (optional)
Specifies the number of significant digits that will be used for formatting matrix values. If p is a scalar, the same precision will be used for real and imaginary parts of m. If p is a vector, the first element of p will specify the precision for the real values and the second element will specify the precision for the imaginary values in m. The default precision used will be the format specified in the application at the time of execution.
Type: scalar | vector
'class' (optional)
A keyword which appends the class of m with the result, R. An evaluation of R would result in the same class of matrix as m, with the same data.
Type: string

Outputs

R
The row delimiter for matrix values is a semicolon, ';'. The column delimiter is white space, ' '.
Type: string

Examples

Default options:
R = mat2str(rand(3,2))
R = [0.54881 0.59284;0.71519 0.84427;0.60276 0.85795]
Scalar precision with the 'class' keyword:
R = mat2str(rand(3,2), 2, 'class')
R = double([0.54 0.85;0.42 0.62;0.65 0.38])
Vector precision:
m = [0.54+pi*i 0.85;0.42 0.62 + 2*pi*i;0.65 0.38+1/3i];
          R = mat2str(m, [2,3])
R = [0.54 + 3.14i 0.85 + 0i;0.42 + 0i 0.62 + 6.28i;0.65 + 0i 0.38 - 0.333i]