time | Calls | line |
---|
| | 129 | function results = canonicalizeNames(obj, names)
|
| | 130 | % Used to match names from partial matches, and replace aliases
|
| | 131 | % with the corrected canonical names
|
< 0.001 | 4 | 132 | names = convertCharsToStrings(names);
|
< 0.001 | 4 | 133 | results.CanonicalNames = names;
|
< 0.001 | 4 | 134 | allNames = obj.ParameterNames;
|
< 0.001 | 4 | 135 | hasAliases = ~isempty(obj.Aliases);
|
| | 136 |
|
| | 137 | % indices of the non-empty, non-missing elements
|
< 0.001 | 4 | 138 | nonZero = find(strlength(names) > 0);
|
| | 139 |
|
| | 140 | % Initialize the struct fields
|
< 0.001 | 4 | 141 | results.NonMatched = strings(0);
|
< 0.001 | 4 | 142 | results.AmbiguousMatch = struct('idx',{},'names',{});
|
| | 143 |
|
0.001 | 4 | 144 | for kk = nonZero
|
< 0.001 | 2 | 145 | if hasAliases
|
0.001 | 2 | 146 | names(kk) = obj.checkAlias(names(kk));
|
< 0.001 | 2 | 147 | end
|
| | 148 |
|
< 0.001 | 2 | 149 | matches = matchPartial(allNames,names(kk));
|
| | 150 |
|
| | 151 | % If multiple matches were found, pick the exact match over a
|
| | 152 | % different partial match
|
< 0.001 | 2 | 153 | if nnz(matches) > 1
|
| | 154 | exactMatch = strcmpi(allNames,names(kk));
|
| | 155 | if nnz(exactMatch) == 1
|
| | 156 | results.CanonicalNames(kk) = allNames(exactMatch);
|
| | 157 | else
|
| | 158 | results.AmbiguousMatch(end+1) = struct('idx',kk,'names',allNames(matches)); %#ok<*AGROW>
|
| | 159 | end
|
< 0.001 | 2 | 160 | elseif nnz(matches) ~= 1
|
| | 161 | results.NonMatched(end+1) = names(kk);
|
< 0.001 | 2 | 162 | else % one (at worst) partial match
|
< 0.001 | 2 | 163 | results.CanonicalNames(kk) = allNames(matches);
|
< 0.001 | 2 | 164 | end
|
< 0.001 | 2 | 165 | end
|
< 0.001 | 4 | 166 | end
|
Other subfunctions in this file are not included in this listing.