time | Calls | line |
---|
| | 766 | function s = getOptsStructWithDefaults(t,sCustom)
|
| | 767 | import matlab.io.*
|
< 0.001 | 12 | 768 | persistent defaults
|
< 0.001 | 12 | 769 | if isempty(defaults)
|
| | 770 | defaults.numeric = makeOptsStruct(matlab.io.NumericVariableImportOptions);
|
| | 771 | defaults.datetime = makeOptsStruct(matlab.io.DatetimeVariableImportOptions');
|
| | 772 | defaults.datetime.FillValue = complex(NaN,0);
|
| | 773 | defaults.duration = makeOptsStruct(matlab.io.DurationVariableImportOptions');
|
| | 774 | defaults.categorical = makeOptsStruct(matlab.io.CategoricalVariableImportOptions');
|
| | 775 | defaults.text = makeOptsStruct(matlab.io.TextVariableImportOptions');
|
| | 776 | defaults.logical = makeOptsStruct(matlab.io.LogicalVariableImportOptions');
|
< 0.001 | 12 | 777 | end
|
| | 778 |
|
< 0.001 | 12 | 779 | switch t
|
| | 780 | % FillValues should be stored in the internal format
|
< 0.001 | 12 | 781 | case {'uint8','uint16','uint32','uint64','int8','int16','int32','int64','double','single','auto'}
|
< 0.001 | 6 | 782 | s = defaults.numeric;
|
< 0.001 | 6 | 783 | s.Type = t;
|
< 0.001 | 6 | 784 | if t == "auto"
|
| | 785 | s.FillValue = 0;
|
< 0.001 | 6 | 786 | else
|
< 0.001 | 6 | 787 | s.FillValue = cast(s.FillValue,t);
|
< 0.001 | 6 | 788 | end
|
< 0.001 | 6 | 789 | case 'datetime'
|
| | 790 | s = defaults.datetime;
|
| | 791 | if isfield(sCustom,'FillValue') && isdatetime(sCustom.FillValue)
|
| | 792 | sCustom.FillValue = datetime.toMillis(sCustom.FillValue);
|
| | 793 | end
|
< 0.001 | 6 | 794 | case 'duration'
|
| | 795 | s = defaults.duration;
|
| | 796 | if isfield(sCustom,'FillValue') && isduration(sCustom.FillValue)
|
| | 797 | sCustom.FillValue = milliseconds(sCustom.FillValue);
|
| | 798 | end
|
< 0.001 | 6 | 799 | case 'logical'
|
| | 800 | s = defaults.logical;
|
< 0.001 | 6 | 801 | case 'categorical'
|
| | 802 | s = defaults.categorical;
|
| | 803 | % Ordinal Implies Protected
|
| | 804 |
|
| | 805 | if isfield(sCustom,'Ordinal') && sCustom.Ordinal
|
| | 806 | s.Protected = true;
|
| | 807 | if isfield(sCustom, 'Protected')
|
| | 808 | sCustom = rmfield(sCustom, 'Protected');
|
| | 809 | end
|
| | 810 | end
|
< 0.001 | 6 | 811 | case {'char','string'}
|
< 0.001 | 6 | 812 | s = defaults.text;
|
< 0.001 | 6 | 813 | s.Type = t;
|
< 0.001 | 6 | 814 | s.FillValue = zeros(0);
|
| | 815 |
|
< 0.001 | 12 | 816 | end
|
< 0.001 | 12 | 817 | for field = fieldnames(sCustom)'
|
| | 818 | s.(field{:}) = sCustom.(field{:});
|
| | 819 | end
|
| | 820 |
|
| | 821 | % cannot create Undefined categorical value with char array '<undefined>'
|
< 0.001 | 12 | 822 | if strcmp(t, 'categorical') && strcmp(s.FillValue, categorical.undefLabel)
|
| | 823 | s.FillValue = '';
|
< 0.001 | 12 | 824 | end
|
| | 825 |
|
< 0.001 | 12 | 826 | end
|
Other subfunctions in this file are not included in this listing.