Create vectors from a table

5 ビュー (過去 30 日間)
Danielle Leblance
Danielle Leblance 2016 年 11 月 21 日
回答済み: Walter Roberson 2016 年 11 月 21 日
Attached is a sample of a large table. I want to create a vector for each column in thetable (i.e 2891 vectors) where the name of each vector is the header of the column in the table (e.g., create a vector called RSSD9999 which is column 1 in the table , another RSSD9001 which is column 2 in the table). how can I do this since manually it takes a lot of time and the size of table and the name of vectors is changing across files.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 11 月 21 日
We recommend against that firmly.
Already, a table acts like a struct for the purpose of dynamic field name access.
V = 'RCON8697';
sample.(V)
and if you do not need to work with the names dynamically then you can just access by field name.
sample.RCON8697
You could also use table2struct() to move directly to struct form, if that is helpful.
fieldnames() can be applied to a table, but it does return the extra names 'Properties', 'Row', and 'Variables' beyond the variable names.

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by