Analysis
Analysis
Report about
(M-file in matlab)
Prepared by :
Supervised by:
Dr.Rafiq Salih
2022-2023
Page | 1
Table Of contents:
Introduction
definition
M-File functions
Anatomy of a M-File function:
Why use m-file ?
How to create,save or open an m-file?
How to run m-file
Script side-effects
Page | 2
Introduction:
• M-File Scripts
• M-File Functions
Page | 3
Definition:
Page | 4
M-File functions:
Page | 5
This simple function shows the basic parts of an M-file.
function f = factorial(n) (1)
% FACTORIAL(N) returns the factorial of N. (2)
% Compute a factorial value. (3)
f = prod(1:n); (4)
The first line of a function M-file starts with the keyword function. It
gives the function name and order of arguments. In the case of
function factorial, there are up to one output argument and one
input argument. Table 4.1 summarizes the M-file function. As an
example,
For
n = 5, the result is,
>> f = factorial(5)
f=
120
Page | 9
Script side-effects :
Page | 10