Wednesday, July 22, 2009

M-Files

You can create your own matrices using M-files, which are text files containing MATLAB code. Use the MATLAB Editor or another text editor to create a file containing the same statements you would type at the MATLAB command line. Save the file under a name that ends in .m. For example, create a file containing these five lines.
A = [ ... 16.0 3.0 2.0 13.0
5.0 10.0 11.0 8.0
9.0 6.0 7.0 12.0
4.0 15.0 14.0 1.0 ];

Store the file under the name magik.m. Then the statement magikreads the file and creates a variable, A, containing our example matrix.

No comments:

Post a Comment