Find column names with particular names in MATLAB table
조회 수: 21 (최근 30일)
이전 댓글 표시
Hi there,
I have a massive table with 408 columns in MATLAB. I want to get rid of columns that start with the word "connected". Instead of having to manually check the table and do something like
finalnbs(:,212:364) = [];
Where
finalnbs
is the table, how do I find all columns in finalnbs which start with connected e.g.
connected*
And then remove those?
댓글 수: 1
채택된 답변
Walter Roberson
2015년 12월 21일
finalnbs(:,strncmp(finalnbs.Properties.VariableNames, 'connected', length('connected')) ) = [];
댓글 수: 0
추가 답변 (2개)
Renato Agurto
2015년 12월 21일
편집: Renato Agurto
2015년 12월 21일
Hello
if "titles" is the first row of your table, then:
titles = finalnbs(1,:);
%Select the columns that should stay
idxs = cellfun(@(x) length(x) < 9 || ~strcmp(x(1:9),'connected'),titles);
finalnbs = finalnbs(:,idxs);
댓글 수: 0
Joseba Moreno
2019년 2월 14일
Hello,
I have a similar problem but in my case I would like to remove the columns which contain the word "free".
How can I do that?
Thanks!
Joseba
댓글 수: 2
Walter Roberson
2019년 2월 14일
With new enough matlab you can use contains() to test whether a substring occurs somewhere in a string .
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!