comparison +grid/equidistant.m @ 886:8894e9c49e40 feature/timesteppers

Merge with default for latest changes
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 15 Nov 2018 16:36:21 -0800
parents c3378418d49a
children
comparison
equal deleted inserted replaced
816:b5e5b195da1e 886:8894e9c49e40
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