time | Calls | line |
---|
| | 398 | function [lia,locb] = ismemberClassTypes(a,b)
|
| 2 | 399 | if issparse(a)
|
| | 400 | a = full(a);
|
| | 401 | end
|
< 0.001 | 2 | 402 | if issparse(b)
|
| | 403 | b = full(b);
|
| | 404 | end
|
| | 405 | % Duplicates within the sets are eliminated
|
< 0.001 | 2 | 406 | if isscalar(a) || isscalar(b)
|
< 0.001 | 2 | 407 | ab = [a(:);b(:)];
|
< 0.001 | 2 | 408 | numa = numel(a);
|
< 0.001 | 2 | 409 | lia = ab(1:numa)==ab(1+numa:end);
|
< 0.001 | 2 | 410 | if ~any(lia)
|
< 0.001 | 2 | 411 | lia = false(size(a));
|
< 0.001 | 2 | 412 | locb = zeros(size(a));
|
< 0.001 | 2 | 413 | return
|
| | 414 | end
|
| | 415 | if ~isscalar(b)
|
| | 416 | locb = find(lia);
|
| | 417 | locb = locb(1);
|
| | 418 | lia = any(lia);
|
| | 419 | else
|
| | 420 | locb = double(lia);
|
| | 421 | end
|
| | 422 | else
|
| | 423 | % Duplicates within the sets are eliminated
|
| | 424 | [uA,~,icA] = unique(a(:),'sorted');
|
| | 425 | if nargout <= 1
|
| | 426 | uB = unique(b(:),'sorted');
|
| | 427 | else
|
| | 428 | [uB,ib] = unique(b(:),'sorted');
|
| | 429 | end
|
| | 430 |
|
| | 431 | % Sort the unique elements of A and B, duplicate entries are adjacent
|
| | 432 | [sortuAuB,IndSortuAuB] = sort([uA;uB]);
|
| | 433 |
|
| | 434 | % Find matching entries
|
| | 435 | d = sortuAuB(1:end-1)==sortuAuB(2:end); % d indicates the indices matching entries
|
| | 436 | ndx1 = IndSortuAuB(d); % NDX1 are locations of repeats in C
|
| | 437 |
|
| | 438 | if nargout <= 1
|
| | 439 | lia = ismemberBuiltinTypes(icA,ndx1); % Find repeats among original list
|
| | 440 | else
|
| | 441 | szuA = size(uA,1);
|
| | 442 | d = find(d);
|
| | 443 | [lia,locb] = ismemberBuiltinTypes(icA,ndx1);% Find locb by using given indices
|
| | 444 | newd = d(locb(lia)); % NEWD is D for non-unique A
|
| | 445 | where = ib(IndSortuAuB(newd+1)-szuA); % Index values of uB through UNIQUE
|
| | 446 | locb(lia) = where; % Return first or last occurrence of A within B
|
| | 447 | end
|
| | 448 | end
|
| | 449 | lia = reshape(lia,size(a));
|
| | 450 | if nargout > 1
|
| | 451 | locb = reshape(locb,size(a));
|
| | 452 | end
|
| | 453 | end
|
Other subfunctions in this file are not included in this listing.