MATLAB: Calculating percentage for row values

percentage

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

Best Answer

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;