-
Notifications
You must be signed in to change notification settings - Fork 1
/
Variable.m
46 lines (38 loc) · 1.13 KB
/
Variable.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
classdef Variable < handle
properties (Access = public)
tag
value = 0
lower = -realmax
upper = realmax
end
properties (Access = private)
type = 'var'
end
methods (Access = public)
function obj = Variable(tag, val, lb, ub)
if nargin < 1
error('Variable needs a "tag".')
end
obj.tag = tag;
if nargin >= 2 && ~isempty(val)
obj.value = val;
end
if nargin >= 3 && ~isempty(lb)
obj.lower = lb;
end
if nargin == 4 && ~isempty(ub)
obj.upper = ub;
end
end
function Show(obj)
fprintf('\n\t Class: %s\n', mfilename)
fprintf('\t Tag: %s\n', obj.tag)
fprintf('\t Value: %2.4e\n', obj.value)
fprintf('\t Lower: %2.4e\n', obj.lower)
fprintf('\t Upper: %2.4e\n', obj.upper)
end
function type = getType(obj)
type = obj.type;
end
end
end