time | Calls | line |
---|
| | 701 | function opts = getTypedOpts(t,args)
|
| | 702 | import matlab.io.*
|
| | 703 | % FillValue may be stored in the low level representation for each type and
|
| | 704 | % valid values may depend on the other args, so assigning it separately
|
| | 705 | % avoids order-or-eval issues.
|
< 0.001 | 30 | 706 | usingFillValue = isfield(args,'FillValue');
|
< 0.001 | 30 | 707 | if usingFillValue
|
| | 708 | fv = args.FillValue;
|
| | 709 | args = rmfield(args,'FillValue');
|
< 0.001 | 30 | 710 | end
|
< 0.001 | 30 | 711 | userSuppliedType = isfield(args,'Type');
|
< 0.001 | 30 | 712 | if userSuppliedType
|
| | 713 | args = rmfield(args,'Type');
|
< 0.001 | 30 | 714 | end
|
< 0.001 | 30 | 715 | switch t
|
< 0.001 | 30 | 716 | case {'uint8','uint16','uint32','uint64','int8','int16','int32','int64','double','single','auto'}
|
0.016 | 15 | 717 | opts = NumericVariableImportOptions('Type',t,args);
|
< 0.001 | 15 | 718 | if usingFillValue, opts.FillValue = fv; end
|
< 0.001 | 15 | 719 | case 'datetime'
|
| | 720 | opts = DatetimeVariableImportOptions(args);
|
| | 721 | if usingFillValue
|
| | 722 | if ismissing(fv)
|
| | 723 | fv = datetime.fromMillis(NaN + 0i);
|
| | 724 | elseif ~isdatetime(fv)
|
| | 725 | fv = datetime.fromMillis(fv);
|
| | 726 | end
|
| | 727 | if ~strcmp(opts.DatetimeFormat, 'default')
|
| | 728 | fv.Format = opts.DatetimeFormat;
|
| | 729 | end
|
| | 730 | opts.FillValue = fv;
|
| | 731 | end
|
< 0.001 | 15 | 732 | case 'duration'
|
| | 733 | opts = DurationVariableImportOptions(args);
|
| | 734 | if usingFillValue
|
| | 735 | if ~isduration(fv)
|
| | 736 | fv = milliseconds(fv);
|
| | 737 | end
|
| | 738 | if ~strcmp(opts.DurationFormat, 'default')
|
| | 739 | fv.Format = opts.DurationFormat;
|
| | 740 | end
|
| | 741 | opts.FillValue = fv;
|
| | 742 | end
|
< 0.001 | 15 | 743 | case 'logical'
|
| | 744 | opts = LogicalVariableImportOptions(args);
|
| | 745 | if usingFillValue, opts.FillValue = fv; end
|
< 0.001 | 15 | 746 | case 'categorical'
|
| | 747 | opts = CategoricalVariableImportOptions(args);
|
| | 748 | if usingFillValue
|
| | 749 | % There's never a reason this should fail unless the categories
|
| | 750 | % were changed after setting the FillValue, in that case, just
|
| | 751 | % assign '', which is Undefined.
|
| | 752 | try
|
| | 753 | opts.FillValue = fv;
|
| | 754 | catch
|
| | 755 | opts.FillValue = '';
|
| | 756 | end
|
| | 757 | end
|
< 0.001 | 15 | 758 | case {'char','string'}
|
0.009 | 15 | 759 | opts = TextVariableImportOptions('Type',t,args);
|
< 0.001 | 15 | 760 | if usingFillValue
|
| | 761 | opts.FillValue_ = fv;
|
< 0.001 | 15 | 762 | end
|
< 0.001 | 30 | 763 | end
|
< 0.001 | 30 | 764 | end
|
Other subfunctions in this file are not included in this listing.