time | Calls | line |
---|
| | 102 | function [paramStruct, otherArgs] = extractArgs(obj,varargin)
|
| | 103 | % Extracts any argments known by this interface, and sets the
|
| | 104 | % others aside. Parameter names are expected to be canonicalized
|
| | 105 | % already. (i.e. partial matching needs to have already been done.)
|
< 0.001 | 2 | 106 | inputNames = varargin(1:2:end)';
|
< 0.001 | 2 | 107 | [inputNames{:}] = convertStringsToChars(inputNames{:});
|
< 0.001 | 2 | 108 | inputNames = convertCharsToStrings(inputNames);
|
< 0.001 | 2 | 109 | allNames = obj.ParameterNames;
|
| | 110 |
|
| | 111 | % Does implicit expansion to find the matches
|
< 0.001 | 2 | 112 | matches = (inputNames(:) == allNames(:)');
|
< 0.001 | 2 | 113 | paramStruct = struct();
|
< 0.001 | 2 | 114 | for n = matches(:,any(matches,1))
|
< 0.001 | 1 | 115 | k = find(n,1,'last');
|
< 0.001 | 1 | 116 | paramStruct.(inputNames(k)) = varargin{2*k};
|
< 0.001 | 1 | 117 | end
|
| | 118 |
|
| | 119 | % None of the values matches the names
|
< 0.001 | 2 | 120 | nonMatches = ~any(matches,2);
|
< 0.001 | 2 | 121 | numArgs = nnz(nonMatches);
|
| | 122 | % Rebuild the other args for non-matches items
|
< 0.001 | 2 | 123 | otherArgs = cell(1,numArgs);
|
< 0.001 | 2 | 124 | otherArgs(1:2:2*numArgs) = cellstr(inputNames(nonMatches));
|
< 0.001 | 2 | 125 | values = varargin(2:2:end)';
|
< 0.001 | 2 | 126 | otherArgs(2:2:2*numArgs) = values(nonMatches);
|
< 0.001 | 2 | 127 | end
|
Other subfunctions in this file are not included in this listing.