Matrix2M

Outputs the m-file commands necessary to recreate a matrix, useful to include constants in m-files.
1K Downloads
Updated 4 Nov 2005

No License

This function takes a variable name, collects its contents from the base workspace and outputs (to the clipboard and the variable OutputCharMatrix) the m-code necessary for MATLAB to re-create the variable, including the variable name.
This is useful for including matrices of constants in m-files.

Accepts full or sparse matrices of real or complex numeric values.

For small 2D matrices, try mat2str instead.
Example:
a=rand(3,3,3);
Matrix2M('a')

Cite As

Thorwald van Vuure (2024). Matrix2M (https://www.mathworks.com/matlabcentral/fileexchange/8933-matrix2m), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on General Physics in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0