Delete rows with strings for a cell array

I have a cell array that contains a few rows of strings and want to delete the whole row if they are all strings.
'Cause' 'CSSR (%)' 'MO Attempts' 'MT Attempts'
[1x20 char] [ 1] [ 1] [ 0]
I only want to delete the first row and not the second.
Thank you

 採用された回答

Andrei Bobrov
Andrei Bobrov 2013 年 6 月 26 日
編集済み: Andrei Bobrov 2013 年 6 月 26 日

1 投票

A = {'Cause' 'CSSR (%)' 'MO Attempts' 'MT Attempts'
'fghytresdfhjjiiuyt' [ 1] [ 1] [ 0]};
out = A(any(~cellfun(@ischar,A),2),:);
or
out = A;
A(all(cellfun(@ischar,A),2),:) = [];

4 件のコメント

Rooy
Rooy 2013 年 6 月 27 日
This takes out the rows that have some strings and numbers, I need to take out the rows that only have strings in it.
Thank you
Matthew Eicholtz
Matthew Eicholtz 2013 年 6 月 27 日
When I run the code, it appears to do what you are asking. The all(...) part ensures that only rows in which every cell contains characters are deleted.
Rooy
Rooy 2013 年 6 月 27 日
I must have changed the code, anyway it works.
Thank you
Sonisa
Sonisa 2016 年 2 月 25 日
I have this format
'Time' 'DOY' 'VWC05' 'VWC10' 'VWC20' 'VWC50' 'T05' 'T10' 'T20' 'T50' 'PAW40' 'PAW65' '#' '#' 'cm^3/cm^3' 'cm^3/cm^3' 'cm^3/cm^3' 'cm^3/cm^3' '°C' '°C' '°C' '°C' 'mm' 'mm'
Which I want to delete it. They are on every 600th row, sometimes in 590th row. How do I delete it so that I can get the value that i want?
Thank you in advance.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2013 年 6 月 26 日

コメント済み:

2016 年 2 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by