time | Calls | line |
---|
| | 1 | function [fill,varData] = processRawFill(fill,varData)
|
| | 2 | % Process Raw Fillvalues into output type.
|
| | 3 |
|
| | 4 | % Copyright 2019 MathWorks, Inc.
|
< 0.001 | 3 | 5 | if isnumeric(varData) && isempty(fill)
|
| | 6 | fill = NaN;
|
< 0.001 | 3 | 7 | end
|
| | 8 |
|
< 0.001 | 3 | 9 | if iscell(varData)
|
< 0.001 | 2 | 10 | if isnumeric(fill)
|
< 0.001 | 2 | 11 | fill = '';
|
< 0.001 | 2 | 12 | end
|
< 0.001 | 2 | 13 | fill = {fill};
|
< 0.001 | 3 | 14 | end
|
| | 15 |
|
| 3 | 16 | if isstring(varData)
|
| | 17 | if isempty(fill)
|
| | 18 | fill = missing;
|
| | 19 | end
|
| | 20 | fill = string(fill);
|
< 0.001 | 3 | 21 | end
|
| | 22 |
|
< 0.001 | 3 | 23 | if isdatetime(varData) && isnumeric(fill)
|
| | 24 | if numel(fill) == 2
|
| | 25 | fill = complex(fill(1),fill(2));
|
| | 26 | end
|
| | 27 | fill = datetime.fromMillis(fill);
|
< 0.001 | 3 | 28 | end
|
| | 29 |
|
< 0.001 | 3 | 30 | if isduration(varData) && isnumeric(fill)
|
| | 31 | fill = milliseconds(fill);
|
< 0.001 | 3 | 32 | end
|
| | 33 |
|
< 0.001 | 3 | 34 | if iscategorical(varData)
|
| | 35 | % Combine the categories of the fill value with the
|
| | 36 | if isempty(fill)
|
| | 37 | fill = categorical(missing);
|
| | 38 | end
|
| | 39 | if ~iscategorical(fill)
|
| | 40 | if ischar(fill)
|
| | 41 | fill = {fill};
|
| | 42 | end
|
| | 43 | fill = categorical(fill);
|
| | 44 | end
|
| | 45 | % data array.
|
| | 46 | cats = union(categories(varData),categories(fill),'stable');
|
| | 47 |
|
| | 48 | % If ordinal, both data and array need to have the
|
| | 49 | % same categories in the same order, so reacreate
|
| | 50 | % both with matching properties
|
| | 51 | fill = categorical(fill,cats,...
|
| | 52 | 'Ordinal',isordinal(varData),...
|
| | 53 | 'Protected',isprotected(varData));
|
| | 54 | varData = categorical(varData,cats,...
|
| | 55 | 'Ordinal',isordinal(varData),...
|
| | 56 | 'Protected',isprotected(varData));
|
| | 57 |
|
< 0.001 | 3 | 58 | end
|
| | 59 |
|
< 0.001 | 3 | 60 | end
|
Other subfunctions in this file are not included in this listing.