Organising a table of data
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I have some tables of data, and for convenience I will just show a small segment of it:
BloodPressure=
123
134
136
234
144
Smokers=
1
0
0
1
1
The rows of both BloodPressure and Smokers correspond, ie. the subject with BloodPressure 123 has a Smokers value of 1 (indicating that they are a smoker).
I would like to organise this table so that I can create a group containing all of the smokers and non-smokers, with their corresponding blood pressure.
I tried doing it using: group1 = data(data.Smokers == 1, 1) to create a group of smokers, where I created data to be
123 1
134 0
136 0
234 1
144 1
(ie. Just grouping the blood pressure and the smokers value together correspondingly.)
however, I get the error: Struct contents reference from a non-struct array object.
I appreciate any help,
thankyou.
1 件のコメント
Peter Perkins
2019 年 4 月 2 日
Based on that error, you DON'T have a table. Figure out what "data" is.
回答 (1 件)
madhan ravi
2019 年 3 月 31 日
Smokers=T(T{:,'Smokers'}==1,1)
Non_Smokers=T(T{:,'Smokers'}==0,1) % where T is your table
1 件のコメント
madhan ravi
2019 年 3 月 31 日
T=table;
T.BloodPressure=[...
123
134
136
234
144]
T.Smokers= [...
1
0
0
1
1]
Smokers=T(T{:,'Smokers'}==1,:)
Non_Smokers=T(T{:,'Smokers'}==0,:)
参考
カテゴリ
Help Center および File Exchange で Descriptive Statistics and Visualization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!