Displaying result more than 50%

4 visualizaciones (últimos 30 días)
kash
kash el 4 de Sept. de 2012
result =
{6x4 cell}
{5x4 cell}
{4x4 cell}
{3x4 cell}
In which the 4th column has percentage i want to display results having more thab 50 %
the 4th column contains different percentages,i want to display above 50% pleasae help
  2 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 4 de Sept. de 2012
Editada: Azzi Abdelmalek el 4 de Sept. de 2012
percentage begins at the seond line? cn you post an example?
TAB
TAB el 4 de Sept. de 2012
Whay is your cell content exactly ? Do you want to display the whole row in which col4 > 50 or just values which are >50 ?

Iniciar sesión para comentar.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 4 de Sept. de 2012
Editada: Andrei Bobrov el 4 de Sept. de 2012
r = result;
for jj = 1:numel(r)
t = cellfun(@(x)isempty(x)|ischar(x),r{jj}(:,end));
t2 = cell2mat(r{jj}(~t,end)) > 50; % corrected 5
if any(t2)
r{jj} = r{jj}([true(nnz(t),1);t2],:);
else
r{jj} = [];
end
end
r = r(~cellfun(@isempty,r),:);
OR
eg
% the initial data
result = {{
'Genes' 'T2&T4' 'T4&T6' []
'YAR029W' 'd' 'd' [60]
'YAR062W' 'ddu' 'ud1' [40]
'YBL095W' 'du' 'ud' [60]};
{
'Genes' 'T2&T4' 'T4&T6' 'ghgh'
'YAR029W' 'd' 'd' [40]
'YAR062W' 'ddu' 'ud1' [40]
'YBL095W' 'du' 'ud' [40]};
{
'Genes' 'T2&T4' 'T4&T6' ''
'YAR029W' 'd' 'd' [40]
'YAR062W' 'ddu' 'ud1' [70]
'YBL095W' 'du' 'ud' [40]}};
% solution
r = result;
for jj = 1:numel(r)
t = cell2mat(r{jj}(2:end,end)) > 50;
if any(t)
r{jj} = r{jj}([true;t],:);
else
r{jj} = [];
end
end
r = r(~cellfun(@isempty,r));
  11 comentarios
Andrei Bobrov
Andrei Bobrov el 4 de Sept. de 2012
corrected 5, :)
kash
kash el 4 de Sept. de 2012
Thans a lot Andrei i gor answer an ver greatful to u

Iniciar sesión para comentar.

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 4 de Sept. de 2012
Editada: Azzi Abdelmalek el 4 de Sept. de 2012
for k=1:length(result)
A=result{k}
A=A([1 ;find(cell2mat(cellfun(@(x) x>50,A(2:end,4),'uni',false)))+1],:)
out{k}=A
end
%I suppose that your data looks like this
'Genes' 'T2&T4' 'T4&T6' 'perc'
'YAR029W' 'd' 'd' [ 60]
'YAR062W' 'ddu' 'ud1' [ 40]
'YBL095W' 'du' 'ud' [ 60]
  14 comentarios
kash
kash el 4 de Sept. de 2012
i tried Azzi but thee sizes are same why do i get like it as i said it consist of different percentage of values if give >50 the percentage above 50 must be displayed and size must gets reduced,am i correct Azzi
please tell
Azzi Abdelmalek
Azzi Abdelmalek el 4 de Sept. de 2012
Editada: Azzi Abdelmalek el 4 de Sept. de 2012
for the example below what should be the answer
'Genes' 'T0&T2' 'ee' 'T4&T6' 'perc'
'YBR074W' 'du' 'rr' 'du' [ 60]
'YBR138C' 'du' 'rr' 'du' [ 60]
'YBR285W' 'du' 'rr' 'du' [ 40]
% I guess
'Genes' 'T0&T2' 'ee' 'T4&T6' 'perc'
'YBR074W' 'du' 'rr' 'du' [ 60]
'YBR138C' 'du' 'rr' 'du' [ 60]

Iniciar sesión para comentar.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by