Академический Документы
Профессиональный Документы
Культура Документы
1st MODULE
Created by:
Ahmad Kanzu Syauqi Firdaus, S.Si
1
TABLE OF CONTENT
CHAPTER I
INTRODUCTION
Command Window: place where all MATLAB commands are written and executed.
Workspace: consist of information about variables inside MATLAB memory.
4
Command History: information about any commands that had been write before.
In MATLAB 2013 or newer version there is “PLOTS” tab which consist of some graph
choice. When cursor directed to one graph, there will be shown the function which is used to
show that graph.
5
In MATLAB 2013 or newer version, there is “APPS” tab which consist of some built-in tool
which can be useful to solve some cases for someone who require.
CHAPTER II
VARIABLE AND OPERATOR
2.1. Variable
2.1.1. Special Variables
Variable Value
ans Any results
pi Comparison between circle circumference with its
diameter
eps Smallest number so that if it is added by one, the
result is a number that greater than one in the
computer
flops The number of floating point operation
inf Infinity
NaN Not number
i and j Imaginer number
nargin The number of function's input argument
nargout The number of function's output argument
realmin The smallest real positive number that can be used
realmax The largest real positive number that can be used
tic dan toc tic = starting point of computation time counter,
toc = stopping point of computation time counter
2.2. Operator
2.2.1. Arithmetic Operator
Operation Operator
Increment +
Decrement -
Matrix rule multiplication *
Matrix element multiplication .*
Matrix rule right division /
Matrix element right division
Matrix rule left division \
Matrix element left division .\
Degree (matrix rule) ^
Degree for matrix element .^
Step :
CHAPTER III
M-FILE
M-file is some MATLAB commands that are written chronologically and saved as a
file. The saved filename will have “*.m” extension which indicate that the file is MATLAB
file. M-file can be written either as a script or a function that receive argument or input which
produce output.
Same as another program, the fundamental principle of MATLAB can be drawn as following:
PROCESS
9
Example:
Results:
10
CHAPTER IV
ARRAY
Array is the association of variables which have the same data type and are expressed
with the same name.
4.2.2. Linspace
CHAPTER V
MATRICES
5.2.2. Ones
Other example:
CHAPTER VI
STATEMENT CONTROL
6.1. If
“If” is statement control that is used to evaluate logical expression and execute amount
statement which based on expression value. If else can be written as follows:
example:
6.2. While
While is used to do looping process during expression condition is satiable. When the
condition is insatiable, the looping process will be stopped directly. The common form of
while is:
while <expression>
Statement
end
20
Example:
6.3. For
For is used to do looping process during the expression condition is satiable. The difference
between for and while is in for, the number of looping can be known, whereas in while is
depend on expression value. The common form of for is:
Example:
6.4. Continue
Continu is continuing to the next iteration without doing statement under the continue
condition.
21
Example:
6.5. Break
Break is used to stop the looping process without continuing the loop. The program codes
after iteration are still executed by MATLAB. Example:
6.6. Return
Return is used to stop the looping process without continuing the loop. The program codes
after iteration are not executed by MATLAB. Example:
22
CHAPTER VII
CELL
CHAPTER VIII
STRUCT
%% Filling Struct
%Filling Class
Data(1).Class='A';
Data(2).Class='B';
Data(3).Class='B';
%Filling Name
A_Class{1,1}='Farah';
A_Class{2,1}='Jack';
A_Class{3,1}='Yuki';
B_Class{1,1}='Yuma';
B_Class{2,1}='Hogan';
B_Class{3,1}='Gerrard';
C_Class{1,1}='Ahmed';
C_Class{2,1}='Eto';
C_Class{3,1}='Bruno';
Data(1).Name=A_Class;
Data(2).Name=A_Class;
Data(3).Name=A_Class;
%Filling ToeflScore
A_Toefl(1,1)=600;
A_Toefl(2,1)=475;
A_Toefl(3,1)=500;
B_Toefl(1,1)=420;
B_Toefl(2,1)=512;
B_Toefl(3,1)=590;
C_Toefl(1,1)=595;
C_Toefl(2,1)=575;
C_Toefl(3,1)=530;
Data(1).ToeflScore=A_Toefl;
Data(2).ToeflScore=A_Toefl;
Data(3).ToeflScore=A_Toefl;
28
CHAPTER IX
INPUTTING DATA
Program code:
9.2.2. Data Is Placed Outside from Default Folder and Is Not The Same Folder As With
M-File
Using “Set Path”
Pastikan terlebih dahulu letak file yang ingin diakses
1 2
Program code:
Results:
34
Results:
(Note: to read *.wav file, the “audioread” function is can be replaced by “wavread”
36