DownloadClassSessionFile - 2024-02-26T205009.417
DownloadClassSessionFile - 2024-02-26T205009.417
DownloadClassSessionFile - 2024-02-26T205009.417
College of Engineering
Software and Informatics Engineering Department
Second Year Class
Numerical Analysis
and
Probability
Lecturer
Kanar Shukr Muhamad
2023-2024
Making variables
Writing who in command window list all the used
variables:
>> who
a ans c
3
Lab Activities
Ac1/ Put ; at the end of the line the command to realize that it
4
Lab Activities
Ac6/ Write a MATLAB command(s) to get two double
quadratic equations.
5
Format Decimal Points in MATLAB
By default, MATLAB uses a 4-digit short
8
MATLAB Files
MATLAB allows you to write a series of commands into a
9
MATLAB Files
MATLAB allows writing two kinds of program files,
which are:
Scripts
11
MATLAB Files
To create m-file, we will make use of MATLAB IDE as
shown below.
12
MATLAB Files
Click on New Script to open a new script file.
13
MATLAB Files
Saving m-file
You will get an untitled file. Let us save the file
as firstmfile.m.
Click on the save button and it will open a popup,
where you can enter the name of the file.
14
MATLAB Files
Click on OK to save the file.
15
MATLAB Files
16
Matlab M-Files - Functions
A function is a group of statements that together perform
a task.
the same.
17
Matlab M-Files - Functions
Functions operate on variables within their own
workspace, which is also called the local workspace.
These functions separate the variables from the
workspace which you access at the MATLAB command
prompt. This is called the base workspace.
19
Function
Declaration function
End
20
Function
After writing the function and saving the file as
the function name, write the function name and
gives value(s) to it’s parameter call and execute
function in the command window.
21
Function
Ac11: Write a function that takes two parameters
(x and y) and return division x by y.
22