EquidistantDomain.m 895 Bytes
Newer Older
1
2
3
4
5
classdef EquidistantDomain < quantity.Domain
	%EQUIDISTANTDOMAIN class to handle the discretization of the range of
	%definition of a function. The discretization points are equally
	%distributed over the domain.
	
6
7
	properties (Access = protected)
		stepSize;
8
9
10
	end
	
	methods
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
		function obj = EquidistantDomain(name, lower, upper, optArgs)
			arguments
				name,
				lower,
				upper,
				optArgs.N = [];
				optArgs.stepSize = [];
			end
			
			if ~isempty(optArgs.stepSize)
				grid = lower : optArgs.stepSize : upper;
			elseif ~isempty(optArgs.N)
				grid = linspace(lower, upper, optArgs.N);
			else
				error('Either number of discretization points or the step size must be defined!')
			end
			
			obj@quantity.Domain(name, grid);
			obj.stepSize = optArgs.stepSize;
30
31
		end
		
32
33
		function d = quantity.Domain(obj)
			d = arrayfun(@(o) quantity.Domain(o.name, o.grid), obj);
34
35
36
37
		end
	end
end