This is a static copy of a profile report

Home

ImportOptions.ImportOptions>ImportOptions.setvartype (Calls: 2, Time: 0.004 s)
Generated 04-Jun-2021 04:11:15 using performance time.
class method in file C:\Program Files\MATLAB\R2020b\toolbox\shared\io\general\+matlab\+io\@ImportOptions\ImportOptions.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...rtOptionsSpreadsheet.getOptsFromSheetclass method2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
308
try type = cellstr(type); catc...
20.001 s35.5%
322
opts.fast_var_opts = v_opts.se...
20.001 s23.4%
314
type = repmat(type,size(select...
20.001 s16.4%
298
type = varargin{2};
20.000 s2.9%
297
selection = find(varargin{1});
20.000 s2.9%
All other lines  0.001 s19.0%
Totals  0.004 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
cellstrfunction20.001 s21.5%
FastVarOpts>FastVarOpts.setTypesclass method20.000 s12.8%
repmatfunction20.000 s6.5%
Self time (built-ins, overhead, etc.)  0.002 s59.3%
Totals  0.004 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function65
Non-code lines (comments, blank lines)30
Code lines (lines that can run)35
Code lines that did run19
Code lines that did not run16
Coverage (did run/can run)54.29 %
Function listing
time 
Calls 
 line
 262 
        function opts = setvartype(opts,varargin)
 263 
            %setvartype
 264 
            %   OPTS = setvartype(OPTS,TYPE) set all variables to the
 265 
            %          specified TYPE by name.
 266 
            %
 267 
            %   OPTS = setvartype(OPTS,NAMES,TYPE) set the variables to the
 268 
            %          specified TYPE by name. NAMES can be a character vector or a
 269 
            %          cell array of character vectors.
 270 
            %
 271 
            %   OPTS = setvartype(OPTS,INDEX,TYPE) set the variables to the
 272 
            %          specified TYPE by index. INDEX must be a vector of positive integers with
 273 
            %          values between 1 and the length of the VARIABLENAMES property of OPTS.
 274 
            %
 275 
            %          TYPE can be any numeric type, 'string, 'char',
 276 
            %          'datetime', 'duration, 'categorical' or 'logical'.
 277 
            %
 278 
            %   See also
 279 
            %   setvaropts, getvaropts, detectImportOptions
 280 
            %   matlab.io.VariableImportOptions
 281 

 282 
            import matlab.io.internal.validators.validateCellStringInput;
 283 

< 0.001 
      2 
 284
            narginchk(2,3); 
< 0.001 
      2 
 285
            if nargout == 0 
 286 
                error(message('MATLAB:textio:io:NOLHS','setvartype','setvartype'))
< 0.001 
      2 
 287
            end 
< 0.001 
      2 
 288
            v_opts = opts.fast_var_opts; 
< 0.001 
      2 
 289
            if nargin == 2 
 290 
                % setvartype(OPTS,TYPE) syntax
 291 
                selection = 1:v_opts.numVars;
 292 
                type = varargin{1};
< 0.001 
      2 
 293
            elseif isnumeric(varargin{1}) 
 294 
                selection = varargin{1};
 295 
                type = varargin{2};
< 0.001 
      2 
 296
            elseif islogical(varargin{1}) 
< 0.001 
      2 
 297
                selection = find(varargin{1}); 
< 0.001 
      2 
 298
                type = varargin{2}; 
 299 
            else
 300 
                selection = validateCellStringInput(convertStringsToChars(varargin{1}), 'SELECTION');
 301 
                if iscell(selection) || ischar(selection)
 302 
                    % Get the appropriate numeric indices and error for unknown variable names.
 303 
                    selection = opts.getNumericSelection(selection);
 304 
                end
 305 
                type = convertStringsToChars(varargin{2});
< 0.001 
      2 
 306
            end 
 307 
            % Convert to cellstr
  0.001 
      2 
 308
            try type = cellstr(type); catch 
 309 
                error(message('MATLAB:textio:textio:InvalidStringOrCellStringProperty','TYPES'));
< 0.001 
      2 
 310
            end 
 311 

 312 
            % Expand scalar
< 0.001 
      2 
 313
            if isscalar(type) 
< 0.001 
      2 
 314
                type = repmat(type,size(selection)); 
 315 
            elseif numel(type) ~= numel(selection)
 316 
                error(message('MATLAB:textio:io:MismatchVarTypes'))
< 0.001 
      2 
 317
            end 
 318 

 319 
            % Set the underlying types
< 0.001 
      2 
 320
            try 
 321 
                %opts.fast_var_opts = v_opts.overrideType(selection,type);
< 0.001 
      2 
 322
                opts.fast_var_opts = v_opts.setTypes(selection, type); 
 323 
            catch ME
 324 
                throw(ME)
< 0.001 
      2 
 325
            end 
< 0.001 
      2 
 326
        end 

Other subfunctions in this file are not included in this listing.