comparison assertSize.m @ 797:5cf9fdf4c98f feature/poroelastic

Merge with feature/grids and bugfix bcSetup
author Martin Almquist <malmquist@stanford.edu>
date Thu, 26 Jul 2018 10:53:05 -0700
parents dec0447cbf2c
children a72038b1f709
comparison
equal deleted inserted replaced
796:aa1ed37a1b56 797:5cf9fdf4c98f
1 % Assert that array A has the size s.
2 function assertSize(A,varargin)
3 if length(varargin) == 1
4 s = varargin{1};
5 errmsg = sprintf('Expected %s to have size %s, got: %s',inputname(1), toString(s), toString(size(A)));
6 assert(all(size(A) == s), errmsg);
7 elseif length(varargin) == 2
8 dim = varargin{1};
9 s = varargin{2};
10
11 errmsg = sprintf('Expected %s to have size %d along dimension %d, got: %d',inputname(1), s, dim, size(A,dim));
12 assert(size(A,dim) == s, errmsg);
13 else
14 error('Expected 2 or 3 arguments to assertSize()');
15 end
16 end