Indexing by using column names
6 views (last 30 days)
Show older comments
I have a table with column names A, B C. I want to create an array col_index=[1 0 1] by using the column names only.
0 Comments
Accepted Answer
Chunru
on 13 Sep 2021
A = zeros(3,1); B=rand(3,1); C=ones(3,1);
T = table(A, B, C)
VarNames = {'A','C'};
col_index = ismember(T.Properties.VariableNames, VarNames)
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!