Professional Documents
Culture Documents
Methods For Calling Functions: Engineering Year 4 Computer Applications ELE-COA-411
Methods For Calling Functions: Engineering Year 4 Computer Applications ELE-COA-411
Engineering Year 4
Computer Applications
ELE-COA-411
MATLAB Programming Part 2
Lesson 4-2019
RS Bakolo, PhD
1
Methods for Calling Functions -Contd
3
function y = fun1(x)
y = x.^2-4;
>>fun1 = ’x.^2-4’;
>>fun_inline = inline(fun1);
>>[x, value] = fzero(fun_inline,[0, 3])
2
Methods for Calling Functions -Contd
5
4. As a string expression:
>>fun1 = ’x.^2-4’;
>>[x, value] = fzero(fun1,[0, 3])
or as
3
Reading Assignment
7
4
Structured Programming
9
10
5
Steps for developing a computer solution
11
11
Documentation
12
12
6
Documenting with Charts
13
13
14
7
Documenting with Pseudocode
15
15
Finding Bugs
16
16
8
Finding Bugs
17
17
Relational Operators
18
>>z = (x < y)
z =
1 0 0
>>z = (x ~= y)
z =
1 1 0
>>z = (x > 8)
z =
0 0 1
RS Bakolo : UNIMA – The Polytechnic : 2019 22-May-19
18
9
Relational Operators Contd
19
z = x(x<y)
19
z = 5 > 2 + 7
is equivalent to
z = 5 >(2+7)
20
10
Logical Class
21
x = (5 > 2)
21
22
22
11
Accessing Arrays Using Logical Arrays
23
23
Logical Operators
24
24
12
Logical Functions
25
25
26
13
Logical Operators and the find Function
27
Note that the find function returns the indices, and not the
values.
27
28
28
14
29 Program Control
29
30
15
for - Loops
31
example 2:
for n = 100:-2:0, k = 1/(exp(n)), end
31
while - Loops
32
32
16
If-elseif-else
33
33
break statement
34
34
17
switch – case - otherwise
35
35
Exercise
36
2. .
36
18