comparison +grid/equidistant.m @ 832:5573913a0949 feature/burgers1d

Merged with default, and updated +scheme/Burgers1D accordingly
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Tue, 11 Sep 2018 15:58:35 +0200
parents c3378418d49a
children
comparison
equal deleted inserted replaced
831:d0934d1143b7 832:5573913a0949
1 % Creates a cartesian grid of dimension length(m).
2 % over the doman xlim, ylim, ...
3 % Examples:
4 % g = grid.equidistant([mx, my], xlim, ylim)
5 % g = grid.equidistant([10, 15], {0,1}, {0,2})
6 function g = equidistant(m, varargin)
7 if length(m) ~= length(varargin)
8 error('grid:equidistant:NonMatchingParameters','The number of provided dimensions do not match.')
9 end
10
11 for i = 1:length(m)
12 if ~iscell(varargin{i}) || numel(varargin{i}) ~= 2
13 error('grid:equidistant:InvalidLimits','The limits should be cell arrays with 2 elements.');
14 end
15
16 if varargin{i}{1} > varargin{i}{2}
17 error('grid:equidistant:InvalidLimits','The elements of the limit must be increasing.');
18 end
19 end
20
21 X = {};
22 h = [];
23 for i = 1:length(m)
24 [X{i}, h(i)] = util.get_grid(varargin{i}{:},m(i));
25 end
26
27 g = grid.Cartesian(X{:});
28 g.h = h;
29 end