0001 function t = dyn_assert(A,B,tol)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if ( (nargin<3) || isempty(tol) )
0023 use_isequal_matlab_builtin = 1;
0024 else
0025 use_isequal_matlab_builtin = 0;
0026 end
0027
0028 [nA,mA] = size(A);
0029 [nB,mB] = size(B);
0030
0031 if nA-nB
0032 error('assert:: Dimensions of compared objects A and B don''t match!')
0033 end
0034
0035 if mA-mB
0036 error('assert:: Dimensions of compared objects A and B don''t match!')
0037 end
0038
0039 if isstruct(B) && ~isstruct(A)
0040 error('assert:: Compared objects are not of the same type!')
0041 end
0042
0043 if iscell(B) && ~iscell(A)
0044 error('assert:: Compared objects are not of the same type!')
0045 end
0046
0047 if use_isequal_matlab_builtin
0048 t = isequal(A,B);
0049 if ~t
0050 t = isequalwithequalnans(A,B);
0051 end
0052 else
0053 t = 1;
0054 if ~(isstruct(B) || iscell(B))
0055 if max(abs(A(:)-B(:)))>tol
0056 t = 0;
0057 end
0058 else
0059
0060 t = NaN;
0061 end
0062 end