-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathexpect_equal.m
More file actions
56 lines (48 loc) · 1.06 KB
/
Copy pathexpect_equal.m
File metadata and controls
56 lines (48 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function ok = expect_equal(x, y)
% only for test purposes
ok = true;
if (iscell(x) & ~iscell(y)) | (~iscell(x) & iscell(y))
error('class mismatch')
end
if ~iscell(x)
x = {x};
y = {y};
end
if ~isequal(size(x), size(y))
error('not equal size of x and y')
end
n = numel(x);
for I = 1: n
X = x{I};
Y = y{I};
if ~isequal(class(X), class(Y))
error('class mismatch')
end
if ~isequal(size(X), size(Y))
error([num2str(I), ': not equal size of X and Y'])
end
if ~iscell(X) & isnan(X)
if isnan(Y)
ok = true;
return
else
error([num2str(I), ': X ~= Y, NaN'])
end
else
if ~iscell(Y) & isnan(Y)
error([num2str(I), ': X ~= Y, NaN'])
end
end
if isnumeric(X)
N = numel(X);
for J = 1: N
if abs(X(J) - Y(J)) > 1e-6
error([num2str(I), ': X ~= Y'])
end
end
else
if ~isequal(X, Y)
error([num2str(I), ': X ~= Y'])
end
end
end