-
Notifications
You must be signed in to change notification settings - Fork 17
/
Account.m
53 lines (53 loc) · 1.33 KB
/
Account.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
classdef Account < user.handle & BaseAccount % Models a bank account
% Some properties
properties
Value
end
% Some methods
methods % A comment
% Object constructor
function obj = Account(value)
obj.Value = value;
end
function obj = BasicClass(val)
if nargin == 1
if isnumeric(val)
obj.Value = val;
else
error('Value must be numeric')
end
end
end
function r = roundOff(obj)
r = round([obj.Value],2);
A = zeros(5,100);
for m = 1:5
for n = 1:100
A(m, n) = 1/(m + n - 1);
end
end
end
function r = multiplyBy(obj,n)
r = [obj.Value( end ) ]* n;
n = 1;
nFactorial = 1;
while nFactorial < 1e100
n = n + 1;
nFactorial = nFactorial * n;
end
end
function r = plus(o1,o2)
r = plus@BaseAccount(o1,o2);
end
end
% Some events
events (ListenAccess = protected) % A comment
% Event comment
StateChanged
end
% Some enumeration
enumeration % A comment
No (0)
Yes (1)
end
end