Deleting words [ ] and 'neutral'

1 回表示 (過去 30 日間)
Pat
Pat 2012 年 7 月 17 日
I have a matrix of values in command window
result=
Columns 1 through 5
'u' 'u' 'd' 'd' 'gene1'
'u' 'u' 'u' 'u' 'gene2'
'd' 'd' 'neutral' 'd' 'gene3'
'd' 'u' 'u' 'u' 'gene4'
'd' 'u' 'd' 'd' 'gene4'
'd' [] [] 'd' 'gene5'
'd' [] [] 'd' 'gene6'
'neutral' 'u' 'u' 'u' 'gene7'
'd' 'u' 'd' 'neutral' 'gene8'
not i want to delete the word 'neutral' and []
please help
[EDITED, Jan, copied from comments]:
i need output as as
'u' 'u' 'd' 'd' 'gene1'
'u' 'u' 'u' 'u' 'gene2'
'd' 'u' 'u' 'u' 'gene4'
'd' 'u' 'd' 'd' 'gene4'
  1 件のコメント
Jan
Jan 2012 年 7 月 17 日
What exactly does "delete" mean? Do you want the row to disappear, or the column, or that the elements are move to the left and the empty matrix is inserted at the right?
Because the resulting cell matrix must be still rectangular, "delete" is not well defined yet.

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

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 7 月 17 日
編集済み: Andrei Bobrov 2012 年 7 月 17 日
EDIT
out = result(all(~cellfun(@(x)isempty(x) | strcmp(x,'neutral'),result),2),:);
or
out = result(~any(cellfun(@(x)isempty(x) | strcmp(x,'neutral'),result),2),:);
  3 件のコメント
Andrei Bobrov
Andrei Bobrov 2012 年 7 月 17 日
編集済み: Andrei Bobrov 2012 年 7 月 17 日
My answer was edited.
Jan
Jan 2012 年 7 月 17 日
result(any(cellfun('isempty', result) | strcmp(result, 'neutral')), :) = [];

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by