Create vectors from a table

조회 수: 2 (최근 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 CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by