Professional Documents
Culture Documents
MATLAB Lab2
MATLAB Lab2
Prepared by:
Ghassan alhazmi
444005350
2023-09-9
OBJECTIVES
Become familiar with m-files.
and
Then
For the later use let us mention briefly a concept of the string in MATLAB. The
character string is a text surrounded by single quotes. For instance,
To illustrate the use of the command feval let us take a closer look at the code in the
m-file mylcm
Command feval checks whether or not both input arguments are integers. If this
condition is satisfied, then the least common multiple is computed using the formula
mentioned earlier, otherwise the error message is generated. Note use of the
command error, which takes as the argument a string. Function that is executed
twice in the body of the function mylcm is named isint
realmin is the smallest positive real number on your computer
The input parameters a and b can be arrays of the same dimension. This is
possible because the dot operator proceeds certain arithmetic operations in the
command that defines the variable y. In this example we will integrate the sine
function over two intervals whose end points are stored in the arrays a and b,
where
Lab review Questions:
Q1. . Evaluate the following MATLAB expressions yourself before
checking the answers in MATLAB:
Q2:
a)
b)
c)
Q3
a)
b)
c)
d)
e)
f)
Q4
2)
3)
4)