time | Calls | line |
---|
< 0.001 | 15 | 1 | classdef NumericVarOptsInputs < matlab.io.internal.shared.DecimalSeparatorInput
|
| | 2 | %NUMERICVAROPTSINPUTS Summary of this class goes here
|
| | 3 | % Detailed explanation goes here
|
| | 4 |
|
| | 5 | % Copyright 2018-2019 The MathWorks, Inc.
|
| | 6 |
|
| | 7 | properties (Parameter)
|
| | 8 | %EXPONENTCHARACTER
|
| | 9 | % A character vector containing characters that are used as an
|
| | 10 | % exponent signifier for a number.
|
| | 11 | %
|
| | 12 | % Example: if ExponentCharacter = 'a' then the text "1.2a3" will be
|
| | 13 | % imported the number 1200.
|
| | 14 | %
|
| | 15 | % See Also matlab.io.NumericVariableImportOptions
|
| | 16 | ExponentCharacter = 'eEdD';
|
| | 17 |
|
| | 18 | %THOUSANDSSEPARATOR
|
| | 19 | % The character which is used to separate the thousands digit.
|
| | 20 | %
|
| | 21 | % Example: if ThousandsSeparator=',' then the text "1,234,000" will be
|
| | 22 | % imported as the number 1234000.
|
| | 23 | %
|
| | 24 | % See Also matlab.io.NumericVariableImportOptions
|
| | 25 | ThousandsSeparator = '';
|
| | 26 |
|
| | 27 | %TRIMNONNUMERIC
|
| | 28 | % A logical value that specifies that all prefixes and suffixes
|
| | 29 | % must be removed leaving only the numeric part.
|
| | 30 | %
|
| | 31 | % See Also matlab.io.NumericVariableImportOptions
|
| | 32 | TrimNonNumeric = false;
|
| | 33 |
|
| | 34 | %NUMBERSYSTEM
|
| | 35 | % A character vector that denotes the number system used
|
| | 36 | % to read a number. Default is decimal.
|
| | 37 | %
|
| | 38 | % Accepted values: decimal | hex | binary
|
| | 39 | %
|
| | 40 | % See Also matlab.io.NumericVariableImportOptions
|
| | 41 | NumberSystem = 'decimal';
|
| | 42 | end
|
| | 43 |
|
| | 44 | methods
|
| | 45 | function obj = set.ExponentCharacter(obj,rhs)
|
| | 46 | rhs = convertStringsToChars(rhs);
|
| | 47 | if ~ischar(rhs) || ~isvector(rhs) || any(~ismember(lower(rhs),'a':'z'))
|
| | 48 | error(message('MATLAB:textio:textio:InvalidExponent'))
|
| | 49 | end
|
| | 50 | obj.ExponentCharacter = rhs;
|
| | 51 | end
|
| | 52 |
|
| | 53 | function obj = set.ThousandsSeparator(obj,rhs)
|
| | 54 | rhs = convertStringsToChars(rhs);
|
| | 55 | if ~isequal(rhs,'') && ~matlab.io.internal.validateScalarSeparator(rhs)
|
| | 56 | error(message('MATLAB:textio:textio:InvalidThosandsSep'));
|
| | 57 | end
|
| | 58 | obj.ThousandsSeparator = rhs;
|
| | 59 | end
|
| | 60 |
|
| | 61 | function obj = set.TrimNonNumeric(obj,rhs)
|
| | 62 | try
|
| | 63 | assert(isscalar(rhs) && ~isnan(rhs) && (islogical(rhs) || isnumeric(rhs)));
|
| | 64 | obj.TrimNonNumeric = logical(rhs);
|
| | 65 | catch
|
| | 66 | error(message('MATLAB:textio:textio:InvalidTrimNonNumeric'));
|
| | 67 | end
|
| | 68 | end
|
| | 69 |
|
| | 70 | function obj = set.NumberSystem(obj,rhs)
|
| | 71 | rhs = convertStringsToChars(rhs);
|
| | 72 | if ~ischar(rhs) || ~isvector(rhs) || any(~ismember(lower(rhs),{'decimal','hex','binary'}))
|
| | 73 | error(message('MATLAB:textio:textio:InvalidNumberSystem'))
|
| | 74 | end
|
| | 75 | obj.NumberSystem = rhs;
|
| | 76 | end
|
| | 77 |
|
| | 78 | end
|
| | 79 | methods (Access = protected)
|
| | 80 |
|
| | 81 | function val = setType(obj,val)
|
| | 82 | import matlab.io.internal.supportedTypeNames
|
| | 83 | val = convertCharsToStrings(val);
|
| | 84 | if ~(isstring(val) && isscalar(val)) ...
|
| | 85 | || ~any(strcmp(val,...
|
| | 86 | {'double','single',...
|
| | 87 | 'int8','uint8',...
|
| | 88 | 'int16','uint16',...
|
| | 89 | 'int32','uint32',...
|
| | 90 | 'int64','uint64','auto'}))
|
| | 91 | if any(strcmp(supportedTypeNames,val))
|
| | 92 | newMsg = [getString(message('MATLAB:textio:io:NumericType')), ...
|
| | 93 | '\n\n',getString(message('MATLAB:textio:io:Setdatatype')), '\n', ...
|
| | 94 | getString(message('MATLAB:textio:io:SetvartypeSyntax',obj.Name,val))];
|
| | 95 | throw(MException('MATLAB:textio:io:StaticOptionsType',newMsg));
|
| | 96 | end
|
| | 97 | error(message('MATLAB:textio:io:NumericType'));
|
| | 98 | end
|
| | 99 | val = char(val);
|
| | 100 | end
|
| | 101 |
|
| | 102 | function val = getType(~,val)
|
| | 103 | if isempty(val), val = 'double';end
|
| | 104 | end
|
| | 105 |
|
| | 106 | function val = setFillValue(obj,val)
|
| | 107 | try
|
| | 108 | assert(isscalar(val)&&(isnumeric(val)||islogical(val)||ismissing(val)));
|
| | 109 | if (obj.Type == "auto")
|
| | 110 | cast(val,'uint64');
|
| | 111 | else
|
| | 112 | cast(val,obj.Type);
|
| | 113 | end
|
| | 114 | catch
|
| | 115 | error(message('MATLAB:textio:io:FillValueType',obj.Type));
|
| | 116 | end
|
| | 117 | end
|
| | 118 |
|
| | 119 | function val = getFillValue(obj,val)
|
| | 120 | if isempty(val) || ismissing(val)
|
| | 121 | val = NaN;
|
| | 122 | end
|
| | 123 | if obj.Type == "auto" && isnan(obj.FillValue_)
|
| | 124 | val = 0;
|
| | 125 | elseif obj.Type == "auto" && ~isnan(obj.FillValue_)
|
| | 126 | val = obj.FillValue_;
|
| | 127 | else
|
| | 128 | val = cast(val,obj.Type);
|
| | 129 | end
|
| | 130 | end
|
| | 131 | end
|
| | 132 | end
|
| | 133 |
|
| | 134 |
|