Beruflich Dokumente
Kultur Dokumente
Note: To change current interface into this typical interface Click Layout Select Layout
Click on Default Then click Layout again Click on command history Choose Docked
a) Command Window To type commands and usually answers (or error messages) will be
appear at this area. >> means Matlab waiting for further instruction.
b) Workspace window Variables that has been define in command window (as well in mfiles) should be listed here.
c) Command history window The past commands are remembered here. We can re-run the
previous command or to edit the command by drag it to command window.
Page 1
Additional: +
Subtraction: - ,
Multiplication: *
Division: /
Power: ^
Example:
>>3+5-7
ans=
1
Or
>>t=3+5-7
t=
1
>>T=2*t+2
T=
4
Note: Variable names Capital letter (A) and small letter (a) will brings difference variable
value.
Prepared by Madam Rabiatul Adawiyah Abdol Aziz (2016)
Page 2
Page 3
Task 4: Trigonometric
(a) Tangent, sine & cosine of argument
Example: cos (15) in radian
>> cos(15)
% without d : radians
ans =
-0.7597
% with d: degree
ans =
0.9659
% without d : radians
ans =
1.0472
% with d: degree
ans =
60.0000
Page 4
>> B = [1;2;3;4;5]
B=
1
2
3
4
5
>> C = [1 2; 3 4; 5 6]
C=
1 2
3 4
5 6
>> C(2,:)
ans =
3
Page 5
Task 7: Logical
In Matlab the integer 1 represents true and 0 represent false.
Example:
>>X = 14
>>X > 10
ans =
1
Example:
>>Y=[0 -1 2 4]
>>Y>2
ans =
0001
Command
Result
Description
Y==2
[0 0 1 0]
Entries equal to 2
Y>2
[0 0 0 1]
greater than 2
Y>=2
[0 0 1 1]
Y<2
[1 1 0 0]
less than
Y<=2
[1 1 1 0]
Y~=2
[1 1 0 1]
not equal to
>>Y<0|Y>1
ans =
0111
Page 6