time | Calls | line |
---|
| | 445 | function [tf,duplicated] = checkDuplicateLabels(obj,labels1,labels2,okLocs)
|
| | 446 | %CHECKDUPLICATELABELS Check for duplicated names.
|
| | 447 |
|
| | 448 | % Check for any duplicate names in names1
|
< 0.001 | 16 | 449 | if nargin == 2 % checkDuplicateLabels(obj,labels1)
|
| | 450 | % names1 is always a cellstr
|
< 0.001 | 16 | 451 | duplicated = false(size(labels1));
|
0.001 | 16 | 452 | [labels1Sorted,lids] = sort(labels1);
|
0.003 | 16 | 453 | duplicated(2:end) = strcmp(labels1Sorted(1:end-1),labels1Sorted(2:end));
|
| | 454 | % Put duplicated back in the original order.
|
< 0.001 | 16 | 455 | duplicated(lids) = duplicated;
|
| | 456 |
|
| | 457 | % Check if any name in names1 is already in names2, except that
|
| | 458 | % names1(i) may be at names2(okLocs(i)). This does not check if
|
| | 459 | % names1 contains duplicates within itself
|
| | 460 | elseif nargin == 4 % checkDuplicateLabels(obj,labels1,labels2,okLocs)
|
| | 461 | % names2 is always a cellstr
|
| | 462 | if ischar(labels1) % names1 is either a single character vector ...
|
| | 463 | tmp = strcmp(labels1, labels2); tmp(okLocs) = false;
|
| | 464 | duplicated = any(tmp);
|
| | 465 | else % ... or a cell array of character vectors
|
| | 466 | duplicated = false(size(labels1));
|
| | 467 | for i = 1:length(labels1) %#ok<CPROPLC>
|
| | 468 | tmp = strcmp(labels1{i}, labels2); tmp(okLocs(i)) = false;
|
| | 469 | duplicated(i) = any(tmp);
|
| | 470 | end
|
| | 471 | end
|
| | 472 |
|
| | 473 | % Check if any name in names1 is already in names2. This does not check if
|
| | 474 | % names1 contains duplicates within itself
|
| | 475 | else % nargin==3, checkDuplicateLabels(obj,labels1,labels2) - least frequent syntax
|
| | 476 | % names2 is always a cellstr
|
| | 477 | if ischar(labels1) % names1 is either a single character vector ...
|
| | 478 | duplicated = any(strcmp(labels1, labels2));
|
| | 479 | else % ... or a cell array of character vectors
|
| | 480 | duplicated = false(size(labels1));
|
| | 481 | for i = 1:length(labels1) %#ok<CPROPLC>
|
| | 482 | duplicated(i) = any(strcmp(labels1{i}, labels2));
|
| | 483 | end
|
| | 484 | end
|
| | 485 |
|
| | 486 |
|
< 0.001 | 16 | 487 | end
|
| | 488 |
|
< 0.001 | 16 | 489 | tf = any(duplicated);
|
| | 490 |
|
< 0.001 | 16 | 491 | if tf && obj.requireUniqueLabels && (nargout == 0)
|
| | 492 | allDups = labels1(duplicated);
|
| | 493 | throwAsCaller(MException(message(obj.DuplicateLabelExceptionID,allDups{1}))); % Report the first dup in the message
|
< 0.001 | 16 | 494 | end
|
< 0.001 | 16 | 495 | end
|
Other subfunctions in this file are not included in this listing.