getvaropts
获取变量导入选项
说明
示例
可以使用 getvaropts 函数访问控制变量导入的变量导入选项对象。
从文件创建导入选项。选项对象是各变量导入选项的集合。
opts = detectImportOptions('patients.xls')opts =
SpreadsheetImportOptions with properties:
Sheet Properties:
Sheet: ''
Replacement Properties:
MissingRule: 'fill'
ImportErrorRule: 'fill'
MergedCellColumnRule: 'placeleft'
MergedCellRowRule: 'placetop'
Variable Import Properties: Set types by name using setvartype
VariableNames: {'LastName', 'Gender', 'Age' ... and 7 more}
VariableTypes: {'char', 'char', 'double' ... and 7 more}
SelectedVariableNames: {'LastName', 'Gender', 'Age' ... and 7 more}
VariableOptions: Show all 10 VariableOptions
Access VariableOptions sub-properties using setvaropts/getvaropts
VariableNamingRule: 'modify'
Range Properties:
DataRange: 'A2' (Start Cell)
VariableNamesRange: 'A1'
RowNamesRange: ''
VariableUnitsRange: ''
VariableDescriptionsRange: ''
To display a preview of the table, use preview
获取指定变量的变量导入选项对象。
varOpts = getvaropts(opts, 'Systolic')varOpts =
NumericVariableImportOptions with properties:
Variable Properties:
Name: 'Systolic'
Type: 'double'
FillValue: NaN
TreatAsMissing: {}
QuoteRule: 'remove'
Prefixes: {}
Suffixes: {}
EmptyFieldRule: 'missing'
Numeric Options:
ExponentCharacter: 'eEdD'
DecimalSeparator: '.'
ThousandsSeparator: ''
TrimNonNumeric: 0
NumberSystem: 'decimal'
要修改变量导入选项,请参阅 setvaropts 和 setvartype 函数参考页。
输入参数
文件导入选项,指定为 detectImportOptions 函数创建的 SpreadsheetImportOptions、DelimitedTextImportOptions 或 FixedWidthImportOptions 对象。opts 对象包含控制数据导入过程的属性,例如变量属性、数据位置属性、替代规则等。
选定的变量,指定为字符向量、字符串标量、字符向量元胞数组、字符串数组、数值索引数组或逻辑数组。
变量的名称(或索引)必须为 opts 对象的 VariableNames 属性中包含的名称的子集。
示例: 'Height'
示例: {'Height','LastName'}
示例: [5 9]
数据类型: char | string | cell | uint64
输出参量
选定变量的类型相关选项,以变量导入选项对象数组形式返回。此数组为 selection 参量中指定的每个变量包含一个对应的对象。根据变量的数据类型,数组中的每个对象可为以下类型之一:数值、文本、logical、datetime 和 categorical。
您可以修改各个对象的属性。
要修改
Type属性,请使用setvartype函数。要修改其他属性,请使用
setvaropts函数。
版本历史记录
在 R2016b 中推出
另请参阅
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)