How do i Filter out table columns headers based on given query words?

조회 수: 7 (최근 30일)
Dear Experiences
i have a table that look like the following:
Table:
Name RC BV CC RQ CY ..... TY
A1 1 0 1 0 1 0
A2 1 0 0 0 0 0
A3 0 1 1 0 1 0
A4 0 0 0 0 0 1
then for the given query word such as ( A1 ) then the result perhaps store in cell array like:
Result ={ RC , CC , CY ,...} where the values of A1 in the corresponding columns header are 1.
i would thanks any one can give me help.

채택된 답변

Walter Roberson
Walter Roberson 2017년 8월 19일
YourTable.Properties.VariableNames( logical(YourTable{1,:}) )
  댓글 수: 1
Peter Perkins
Peter Perkins 2017년 8월 23일
You could also make Name the row names, i which case Walter's answer looks like
YourTable.Properties.VariableNames( logical(YourTable{'A1',:}) )

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KL
KL 2017년 8월 19일
x = rand(3,3);
rowX = {'A1','A2','A3'};
xT = array2table(x,'RowNames',rowX)
xA1 = table2cell(xT({'A1'},:))
  댓글 수: 2
ahmed obaid
ahmed obaid 2017년 8월 19일
thanks, your code its retrieve the values of first row A1, while my request perhaps retrieve the columns headers, so according to my example in the above table the result of A1 ={RC, CC, CY} because the values of A1 row are 1 in these columns headers.
KL
KL 2017년 8월 19일
Oh yes. Check out Walter's answer.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by