Delete rows from string array with just one value

2 ビュー (過去 30 日間)
Tatjana Mü
Tatjana Mü 2022 年 3 月 24 日
編集済み: Henry Barth 2022 年 3 月 25 日
Hi,
I have a string array like this:
x=[Na,Mg,Si ; V ; Na,Mg,Si,S ; Si ; Na,Mg,Al,P]
I want to delete all the rows which contain just one Value. Does somebody has an idea how it could work? Because I reached my limit of knowledge (really new in matlab).
I appreciate any idea :-)
  2 件のコメント
Henry Barth
Henry Barth 2022 年 3 月 24 日
are Na,Mg,Si string variables?
Tatjana Mü
Tatjana Mü 2022 年 3 月 24 日
Yes, the string array just contains Elements as string variables. The problem is that they change from sample to sample, depends on the sample. Sometimes the elements stands alone in a row, but also in rows with other elements, so I cant just delete the elementname. I need a solution to general delete rows with just one value. I hope you understand what I mean.

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

採用された回答

Arif Hoq
Arif Hoq 2022 年 3 月 24 日
編集済み: Arif Hoq 2022 年 3 月 24 日
as i don't have your data so i have added NaN string to make the same dimension cell array
x={'Na','Mg','Si' NaN; 'V' NaN NaN NaN; 'Na','Mg','Si','S' ; 'Si' NaN NaN NaN; 'Na','Mg','Al','P'};
a=string(x);
y=rmmissing(a,1,'MinNumMissing',2);
output=cellstr(y)
output = 3×4 cell array
{'Na'} {'Mg'} {'Si'} {0×0 char} {'Na'} {'Mg'} {'Si'} {'S' } {'Na'} {'Mg'} {'Al'} {'P' }
  8 件のコメント
Arif Hoq
Arif Hoq 2022 年 3 月 24 日
~ supposed to mean not.
~= menas not equal.
isequal function returns empty cell. so ~ which is used before isempty fucntion returns not empty cell
Henry Barth
Henry Barth 2022 年 3 月 24 日
Isn't that what I said? Please correct me if I'm wrong!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by