Daniel@0: function assert(pred, str) Daniel@0: % ASSERT Raise an error if the predicate is not true. Daniel@0: % assert(pred, string) Daniel@0: Daniel@0: if nargin<2, str = ''; end Daniel@0: Daniel@0: if ~pred Daniel@0: s = sprintf('assertion violated: %s', str); Daniel@0: error(s); Daniel@0: end