calculating percentage for row values

1 回表示 (過去 30 日間)
Pat
Pat 2012 年 8 月 18 日
final =
'Genes' 'T0&T2' 'T1&T3' 'T2&T4' 'T3&T5' 'T4&t6'
'YAR029W' 'd' [] 'd' [] 'd'
'YBL095W' 'd' [] [] 'd' 'd'
'YBL111C' 'u' 'u' 'u' 'u' []
'YBL113C' 'u' 'u' 'u' 'u' 'u'
'YBR096W' 'u' 'u' 'u' 'u' []
'YBR138C' 'd' [] [] 'd' 'd'
I have a above matrix in which i want to calculate the percentage for every gene
for example 'YAR029W' has 3 values so percentage is 60%(3/5*100)
'YBL095W'- 60%
'YBL111C' -80%
YBL113C' -100%
i need to perform for all genes,please help

採用された回答

Wayne King
Wayne King 2012 年 8 月 18 日
One thing you can do
emptycells = cell2mat(cellfun(@(x) ~isempty(x),final,'uni',0));
perempty = sum(emptycells(2:end,2:end),2);
perempty = (perempty./5)*100;
  1 件のコメント
Jan
Jan 2012 年 8 月 28 日
~cellfun('isempty', C) is more efficient than ~cellfun(@isempty, C). But with anonymous functions, cellfun is even slower.

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

その他の回答 (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