Displaying result more than 50%
4 views (last 30 days)
Show older comments
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 Comments
Azzi Abdelmalek
on 4 Sep 2012
Edited: Azzi Abdelmalek
on 4 Sep 2012
percentage begins at the seond line? cn you post an example?
TAB
on 4 Sep 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 ?
Accepted Answer
Andrei Bobrov
on 4 Sep 2012
Edited: Andrei Bobrov
on 4 Sep 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 Comments
More Answers (1)
Azzi Abdelmalek
on 4 Sep 2012
Edited: Azzi Abdelmalek
on 4 Sep 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 Comments
Azzi Abdelmalek
on 4 Sep 2012
Edited: Azzi Abdelmalek
on 4 Sep 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]
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!