See other catalogues for
The MathWorks
You may also be interested in
Text version of the page
| | | | | | | | | | | | | |
| | | |
| | | Working with Matrices | | |
| | | |
| | | R = randn(4,4) R= 0.6353 0.0860 -0.3210 -1.2316 -0.6014 -2.0046 1.2366 1.0556 0.5512 -0.4931 -0.6313 -0.1132 -1.0998 0.4620 -2.3252 0.3792 The load Function The load function reads binary files containing matrices generated by earlier MATLAB sessions, or reads text files containing numeric data. The text file should be organized as a rectangular table of numbers, separated by blanks, with one row per line, and an equal number of elements in each row. For example, outside of MATLAB, create a text file containing these four lines: | | |
| | | |
| | | | | | | | | | | | 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 | | | | | | | | | | | |
| | | |
| | | Savethefileas magik .dat in the current directory. The statement load magik.dat reads the file and creates a variable, magik, containing the example matrix. An easy way to read data into MATLAB from many text or binary formats is to use the Import Wizard. | | |
| | | |
| | | 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 in the current directory named magik.m containing thesefivelines: | | |
| | | |
| | | 2-17 | | |
| | | |
| | | | | | | | | | | | | |