[What are M-files | How to make them | A Function M-file A Command M-file ] What are M-filesM-files are files that contain a collection of MATLAB commands or are used to define new MATLAB functions. (Read about 'Simple Function M-Files' on page 41 of ODE using MATLAB to learn more about M-files.) For the purposes of this class, we will only need very simple M-files used to define new functions. However, you may find them useful for other parts of your homework as well. For example you may put a bunch of MATLAB commands into an M-file and then run all of those commands at the MATLAB prompt simply by typing the name of the M-file. How to make M-files in General
An Example Function M-fileHere is an example of a function M-file for use in Example 1 of the assignment on numerical ODE.
Assuming this file is saved as firstode.m then when you type at the MATLAB command prompt >> firstode(1.7,2.3) you will get ans =-0.6950 which is approximately sin(1.7*2.3). An Example Command M-fileHere is an example of an M-file containing a few commands.
Assuming this file is saved as tryme.m then when you type at the MATLAB command prompt >> tryme you will get: ans = [What are M-files | How to make them | A Function M-file A Command M-file ] |
Jump to Bruce Driver's Homepage. Jump to Current Courses Page.
|