Using a column of cells as variable names in a table
조회 수: 18 (최근 30일)
이전 댓글 표시
Hi!
I have a table that contains 2 columns each having 28 rows. The first column contains cells of strings, and the second one contains numbers in cell format. I want to use the individual strings from column 1 as the varible names for a table and then assign the numbers from 2nd column to those variables. How do I do that? The file is attached.
Any help will be appreciated.
댓글 수: 0
답변 (2개)
Sulaymon Eshkabilov
2023년 2월 18일
Here is how to get this assignment done:
T = readtable('Properties.xlsx');
T2 = table(T.Var2, 'RowNames',T.Var1)
T2 = rows2vars(T2)
T2.a1
T2.b1
T2.t1
T2.E_steel
...
댓글 수: 2
Seth Furman
2023년 3월 14일
편집: Seth Furman
2023년 3월 14일
See unstack.
t1 = readtable("Properties.xlsx")
t2 = unstack(t1,"Var2","Var1")
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!