Find column names with particular names in MATLAB table

40 ビュー (過去 30 日間)
Dhruv Ghulati
Dhruv Ghulati 2015 年 12 月 21 日
コメント済み: Peter Perkins 2019 年 2 月 17 日
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) = [];
is the table, how do I find all columns in finalnbs which start with connected e.g.
And then remove those?
  1 件のコメント
harjeet singh
harjeet singh 2015 年 12 月 21 日
please upload mat table, and let me know the datatype of finalnbs



Walter Roberson
Walter Roberson 2015 年 12 月 21 日
finalnbs(:,strncmp(finalnbs.Properties.VariableNames, 'connected', length('connected')) ) = [];

その他の回答 (2 件)

Renato Agurto
Renato Agurto 2015 年 12 月 21 日
編集済み: Renato Agurto 2015 年 12 月 21 日
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);

Joseba Moreno
Joseba Moreno 2019 年 2 月 14 日
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?
  2 件のコメント
Peter Perkins
Peter Perkins 2019 年 2 月 17 日
or strfind in older versions.


Community Treasure Hunt

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

Start Hunting!

Translated by