Displaying result more than 50%
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Azzi Abdelmalek
il 4 Set 2012
Modificato: Azzi Abdelmalek
il 4 Set 2012
percentage begins at the seond line? cn you post an example?
TAB
il 4 Set 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 ?
Risposta accettata
Andrei Bobrov
il 4 Set 2012
Modificato: Andrei Bobrov
il 4 Set 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 Commenti
Più risposte (1)
Azzi Abdelmalek
il 4 Set 2012
Modificato: Azzi Abdelmalek
il 4 Set 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 Commenti
Azzi Abdelmalek
il 4 Set 2012
Modificato: Azzi Abdelmalek
il 4 Set 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]
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!