Deleting [ ] from a matrix

2 ビュー (過去 30 日間)
Pat
Pat 2012 年 7 月 20 日
'gene1' [] 'u' 'u' 'd'
'gene2' 'u' 'u' [] 'u'
'gene3' [] 'u' 'd' []
'gene4' 'd' 'u' 'd' 'd'}
in this matrix [] must be deleted and output as
'gene1' 'u' 'u' 'd'
'gene2' 'u' 'u' 'u'
'gene3' 'u' 'd'
'gene4' 'd' 'u' 'd' 'd'
is it possible please help

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 7 月 20 日
d ={'gene1' [] 'u' 'u' 'd'
'gene2' 'u' 'u' [] 'u'
'gene3' [] 'u' 'd' []
'gene4' 'd' 'u' 'd' 'd'}
out = cellfun(@(x)x(~cellfun(@isempty,x)),num2cell(d,2),'un',0);
  1 件のコメント
Pat
Pat 2012 年 7 月 20 日
Thanks a lot Andrei

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 7 月 20 日
No, you are trying to create a cell array with a variable number of columns per row. That is not allowed.
The closest you would be able to get would be to change to a cell vector, one entry per row, each entry of which contained a cell vector, the entries of which were the strings. e.g.,
YourVector{3} = {'gene3' 'u' 'd'}

カテゴリ

Help Center および File ExchangeGenomics and Next Generation Sequencing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by