rize
rize

Reputation: 859

Matlab: Referring to dataset column with a variable containing the column name

I have a dataset with couple of columns with pre-defined names. I would like to access a column in this dataset by using a variable, which contains the column name in char-type. How should I do the referencing?

I've tried:

dataset.variableName

which doesn't work.

Many thanks for help.

Upvotes: 1

Views: 559

Answers (1)

Shai
Shai

Reputation: 114926

Use parentheses for dynamic field names:

 dataset.(variableName)

Upvotes: 1

Related Questions