Mercurial > repos > public > sbplib
comparison assertSize.m @ 890:c70131daaa6e feature/d1_staggered
Merge with feature/poroelastic.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Wed, 21 Nov 2018 18:29:29 -0800 |
parents | dec0447cbf2c |
children | a72038b1f709 |
comparison
equal
deleted
inserted
replaced
885:18e10217dca9 | 890:c70131daaa6e |
---|---|
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 |