time | Calls | line |
---|
| | 1 | function t = ne(a,b)
|
| | 2 | %NE Not equal for categorical arrays.
|
| | 3 | % A ~= B does element by element comparisons between the categorical arrays A
|
| | 4 | % and B and returns an array with elements set to logical 1 (TRUE) where the
|
| | 5 | % relation is true and elements set to logical 0 (FALSE) where it is not. A
|
| | 6 | % and B must have compatible sizes. In the simplest cases, they can be the
|
| | 7 | % same size or one can be a scalar. Two inputs have compatible sizes if, for
|
| | 8 | % every dimension, the dimension sizes of the inputs are either the same or
|
| | 9 | % one of them is 1.
|
| | 10 | %
|
| | 11 | % C = NE(A,B) is called for the syntax 'A ~= B'.
|
| | 12 | %
|
| | 13 | % If A and B are both ordinal, they must have the same sets of categories,
|
| | 14 | % including their order. If neither A nor B are ordinal, they need not have
|
| | 15 | % the same sets of categories, and the test is performed by comparing the
|
| | 16 | % category names of each pair of elements.
|
| | 17 | %
|
| | 18 | % A ~= S or S ~= A, where S is a scalar string or character vector, returns
|
| | 19 | % a logical array the same size as A, containing logical 1 (true) where the
|
| | 20 | % corresponding elements of A are not equal to the category S.
|
| | 21 | %
|
| | 22 | % Undefined elements are not comparable to any other categorical values,
|
| | 23 | % including other undefined elements. NE returns logical 1 (true) where
|
| | 24 | % elements of A or B are undefined.
|
| | 25 | %
|
| | 26 | % See also EQ.
|
| | 27 |
|
| | 28 | % Copyright 2006-2020 The MathWorks, Inc.
|
| | 29 |
|
2.024 | 269115 | 30 | [acodes,bcodes] = reconcileCategories(a,b,false);
|
| | 31 |
|
| | 32 | % Undefined elements are not equal to everything.
|
0.011 | 269115 | 33 | if isscalar(acodes) % faster scalar case
|
0.017 | 269115 | 34 | if acodes > 0 % categorical.undefCode
|
0.011 | 263725 | 35 | t = (acodes ~= bcodes);
|
< 0.001 | 5390 | 36 | else
|
0.007 | 5390 | 37 | t = true(size(bcodes));
|
0.011 | 269115 | 38 | end
|
| | 39 | elseif isscalar(bcodes) % faster scalar case
|
| | 40 | if bcodes > 0 % categorical.undefCode
|
| | 41 | t = (acodes ~= bcodes);
|
| | 42 | else
|
| | 43 | t = true(size(acodes));
|
| | 44 | end
|
| | 45 | else
|
| | 46 | t = (acodes ~= bcodes) | (acodes == 0) | (bcodes == 0);
|
0.987 | 269115 | 47 | end
|
Other subfunctions in this file are not included in this listing.