メインコンテンツ

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

getvaropts

R2026a

変数インポート オプションの取得

説明

varOpts = getvaropts(opts,selection) は selection で指定された変数の変数インポート オプションを返します。

例

例

すべて折りたたむ

関数 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 オブジェクトには、変数プロパティ、データの位置プロパティ、置換ルールなど、データのインポート プロセスを制御するプロパティが含まれます。

選択した変数。文字ベクトル、string スカラー、文字ベクトルの cell 配列、string 配列、数値インデックスの配列、または logical 配列として指定します。

変数名 (またはインデックス) は、opts オブジェクトの VariableNames プロパティに含まれる名前のサブセットでなければなりません。

例: 'Height'

例: {'Height','LastName'}

例: [5 9]

データ型: char | string | cell | uint64

出力引数

すべて折りたたむ

選択した変数の型依存オプション。変数インポート オプション オブジェクトの配列として返します。配列には、selection 引数で指定された各変数に対応するオブジェクトが含まれます。変数のデータ型により、配列の各オブジェクトは数値、テキスト、logical、datetime および categorical のいずれかの型になります。

それぞれのオブジェクトのプロパティは変更することができます。

  • Type プロパティを変更するには、関数 setvartype を使用。

  • 他のプロパティを変更するには、関数 setvaropts を使用。

バージョン履歴

R2016b で導入