calculating percentage value and cancanating
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have values as
gene =
{6x3 cell}
{6x4 cell}
{5x5 cell}
{4x6 cell}
{3x6 cell}
{2x6 cell}
In gene{1,1}
'Genes' 'T0&T2' 'T2&T4' 'T4&T6'
'YAR029W' 'd' 'd' 'd'
'YAR062W' 'du' 'ud' 'du'
'YAR068W' 'du' 'uu' 'uu'
'YBL095W' 'du' 'ud' 'du'
'YBL111C' 'uu' 'ud' 'du'
'YBL113C' 'uu' 'uu' 'ud'
i want to calculate percentage starting from 3rd row
result{1,1}
'Genes' 'T0&T2' 'T2&T4' 'T4&T6' ''
'YAR029W' 'd' 'd' 'd' ''
'YAR062W' 'du' 'ud' 'du' 60
'YAR068W' 'du' 'uu' 'uu' 60
'YBL095W' 'du' 'ud' 'du' 60
'YBL111C' 'uu' 'ud' 'du' 60
'YBL113C' 'uu' 'uu' 'ud' 60
percentage is calclated by (no of rows/5*100)=3/5*100
i tried
emptycells = cell2mat(cellfun(@(x) ~isempty(x),gene,'uni',0));
perempty = sum(emptycells(2:end,2:end),2);
perempty = (perempty./5)*100;
result=[gene(2:end,2:end) perempty]
but get error ,getting all values as zeros
0 comentarios
Respuesta aceptada
Andrei Bobrov
el 3 de Sept. de 2012
result = gene;
for jj = 1:numel(gene)
emptycells = cell2mat(cellfun(@(x) ~isempty(x),result{jj},'un',0));
perempty = sum(emptycells(2:end,2:end),2)./5*100;
result{jj} =[result{jj} [{''};num2cell(perempty)]];
end
0 comentarios
Más respuestas (1)
Azzi Abdelmalek
el 3 de Sept. de 2012
A={'Genes' 'T0&T2' 'T2&T4' 'T4&T6'
'YAR029W' 'd' 'd' 'd'
'YAR062W' 'du' [] 'du'
'YAR068W' 'du' 'uu' 'uu'
'YBL095W' 'du' 'ud' 'du'
'YBL111C' 'uu' 'ud' 'du'
'YBL113C' 'uu' 'uu' 'ud'};
[n,m]=size(A)
B=cellfun(@(x) ~isempty(x),A)
perc=(sum(B(3:end,2:end),2)/5)*100
A{1,m+1}='perc';
A(3:end,m+1)=num2cell(perc)
Ver también
Categorías
Más información sobre Genomics and Next Generation Sequencing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!