getvaropts
Import options of selected variables in an import-options object.
Category: Language Fundamentals > Data Types
Syntax
vo = getvaropts(opts, vars)
Returns the variable import options for the named variables (or indices).
Description
The returned object lists how a column is read: its Type, the FillValue used for missing entries, strings treated as missing, and type-specific settings such as the decimal separator for numbers. Change them with setvaropts and pass the modified opts to readtable.
Input arguments
opts- Import options object, such as one made by
detectImportOptionsordelimitedTextImportOptions. vars- Variable name, cell array of names, or numeric indices.
Output arguments
vo- A variable-options object (for example
NumericVariableImportOptions) for one variable, or a cell array of them for several.
Example
Options of one variable
opts = delimitedTextImportOptions('NumVariables', 2);
opts.VariableNames = {'id', 'score'};
opts = setvartype(opts, 'score', 'double');
v = getvaropts(opts, 'score');
disp(v.Type)
disp(v.FillValue)
Output
double
NaN
See also
setvaropts setvartype detectImportOptions readtable delimitedTextImportOptions