how to extract all columns in between two variable names (column header) of a table?
11 ビュー (過去 30 日間)
古いコメントを表示
Age = [38;43;38;40;49];
Smoker = logical([1;0;1;0;1]);
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
T = table(Age,Smoker,Height,Weight)
I wan't to extract the columns of a table by their variable names rather than by matrix indices. For example 'Age' and 'weight' coulmns of table T can be extracted as
T(:,{'Age', 'Weight'})
But how do I extract all the columns from 'Age' to 'Weight' ? The following syntax doesn't work
T(:,{'Age':'Weight'})
Please suggest if you have a solution. Thank you.
0 件のコメント
採用された回答
Stephen23
2021 年 3 月 29 日
Age = [38;43;38;40;49];
Smoker = logical([1;0;1;0;1]);
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
T = table(Age,Smoker,Height,Weight)
L = 'Age';
R = 'Weight';
[X,Y] = ismember({L,R},T.Properties.VariableNames);
T(:,Y(1):Y(2))
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!