Function Reference
— Function File: s = mat2str (x, n)
— Function File: s = mat2str (..., 'class')

Format real/complex numerical matrices as strings. This function returns values that are suitable for the use of 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 17.

If the argument 'class' is given, then the class of x is included in the string in such a way that the 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])'

See also: sprintf int2str