diff --git a/matlab/utilities/general/compare_vectors.m b/matlab/utilities/general/compare_vectors.m index 9f9064aea..57904535f 100644 --- a/matlab/utilities/general/compare_vectors.m +++ b/matlab/utilities/general/compare_vectors.m @@ -42,14 +42,20 @@ if ~ismember(func2str(f),{'lt', 'gt', 'le', 'ge'}) error('compare_vectors:: First input argument must be one of the following function handles: @lt, @gt, @le or @ge!') end -if feval(f, A(1), B(1)) - C = 1; -elseif isequal(A(1),B(1)) && length(A)>1 - C = compare_vectors(f, A(2:end), B(2:end)); -elseif isequal(A(1),B(1)) && isequal(length(A),1) && ismember(func2str(f),{'le', 'ge'}) - C = 1; +if isequal(length(A),1) + if feval(f, A, B) + C = 1; + else + C = 0; + end else - C = 0; + if feval(f, A(1), B(1)) + C = 1; + elseif isequal(A(1),B(1)) + C = compare_vectors(f, A(2:end), B(2:end)); + else + C = 0; + end end %@test:1