This is a static copy of a profile report

Home

Function details for ismember>ismemberClassTypesThis is a static copy of a profile report

Home

ismember>ismemberClassTypes (Calls: 2, Time: 0.002 s)
Generated 28-Jul-2019 11:53:05 using performance time.
subfunction in file C:\Program Files\MATLAB\R2019a\toolbox\matlab\ops\ismember.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ismember>ismemberR2012asubfunction2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
409
lia = ab(1:numa)==ab(1+numa:en...
20.000 s20.8%
407
ab = [a(:);b(:)];
20.000 s12.4%
406
if isscalar(a) || isscalar(b)
20.000 s12.0%
413
return
20.000 s9.6%
411
lia  = false(size(a));
20.000 s7.7%
All other lines  0.001 s37.6%
Totals  0.002 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function56
Non-code lines (comments, blank lines)8
Code lines (lines that can run)48
Code lines that did run10
Code lines that did not run38
Coverage (did run/can run)20.83 %
Function listing
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.