DOC PREVIEW
ASU MAT 275 - Function M-Files

This preview shows page 1 out of 2 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Function M Files Function M files are like Script M files but can pass parameters and isolate variables These capabilities can be used to add new functions to MATLAB s list perform computational experiments and prepare graphics Example 1 Create a function M file for the function f x x 3 2 Execute edit at the command line to open the editor Enter the following function y f x y x 3 2 Save as prompted namely f m You may now use the function file to compute f 3 f 4 etc Example 2 Create a function M file for the function y of an object above the ground after t seconds 42 644 t 1 e t where y is the height 5 5 Open a new M file in the editor Enter function y height t y 42 5 t 644 5 1 exp t Save as height m You may now use the function file to compute height 3 height 5 etc Example 3 Plot the height function in example 2 and use the graph to estimate the maximum height Open a new M file in the editor Enter function examp2 AcroPDF A Quality PDF Writer and PDF Converter to create PDF files To remove the line buy a license close all t linspace 0 15 200 y height t plot t y grid on xlabel time in seconds ylabel height in meters title Graph of Function in Example 2 function y height t y 42 5 t 644 5 1 exp t Save the file as examp2 m Use Debug Run to execute with F5 AcroPDF A Quality PDF Writer and PDF Converter to create PDF files To remove the line buy a license


View Full Document

ASU MAT 275 - Function M-Files

Download Function M-Files
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Function M-Files and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Function M-Files and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?