Displaying result more than 50%

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

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 4일
편집: Azzi Abdelmalek 2012년 9월 4일
percentage begins at the seond line? cn you post an example?
TAB
TAB 2012년 9월 4일
Whay is your cell content exactly ? Do you want to display the whole row in which col4 > 50 or just values which are >50 ?

댓글을 달려면 로그인하십시오.

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 9월 4일
편집: Andrei Bobrov 2012년 9월 4일

0 개 추천

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

kash
kash 2012년 9월 4일
am getting error
Undefined function or method 'gt' for input arguments of type 'cell'.
Andrei Bobrov
Andrei Bobrov 2012년 9월 4일
corrected
kash
kash 2012년 9월 4일
Even this code is producing wrong result
Andrei Bobrov
Andrei Bobrov 2012년 9월 4일
corrected 2
Andrei Bobrov
Andrei Bobrov 2012년 9월 4일
corrected 3
kash
kash 2012년 9월 4일
Andrei i get following error
??? Error using ==> cell2mat at 47 All contents of the input cell array must be of the same data type.
Andrei Bobrov
Andrei Bobrov 2012년 9월 4일
corrected 4 :)
Thanks andrei i get result but have two problems in the result
1)the values are rearranged as
r =
{6x4 cell}
{5x4 cell}
{4x4 cell}
{1x4 cell}
y do i get {1x4} it displays only the heading and is empty why is it displayed
kash
kash 2012년 9월 4일
i get same size if choosen >50,the size must be reduced {1x4} must not be displayed am i correct Andrei
Andrei Bobrov
Andrei Bobrov 2012년 9월 4일
corrected 5, :)
kash
kash 2012년 9월 4일
Thans a lot Andrei i gor answer an ver greatful to u

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 4일
편집: Azzi Abdelmalek 2012년 9월 4일

0 개 추천

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

kash
kash 2012년 9월 4일
getting error
Error using ==> cellfun Non-scalar in Uniform output, at index 2, output 1. Set 'UniformOutput' to false.
my data is in
result{1,1} i have all genes 60%
result{2,1} i have all genes 20%
result{3,1} i have all genes 100%
result{4,1} i have all genes 40%
so only result{1,1} and result{3,1} must be displayed
Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 4일
편집: Azzi Abdelmalek 2012년 9월 4일
we have just to make this change
A=A([1 ;find(cell2mat(cellfun(@(x) x>50,A(2:end,4),'uni',false)))+1],:)
and why result{1,1} will not be displayed (60%>50%)
kash
kash 2012년 9월 4일
Undefined function or method 'find' for input arguments of type 'cell'.
it's corrected
A=A([1 ;find(cell2mat(cellfun(@(x) x>50,A(2:end,4),'uni',false)))+1],:)
kash
kash 2012년 9월 4일
error
Error using ==> cat CAT arguments dimensions are not consistent.
Error in ==> cell2mat at 89 m{n} = cat(1,c{:,n});
Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 4일
can you post sample of your data?
result(from varible editor )
<1001x5 cell>
<1000x5 cell>
<999x6 cell>
<998x5 cell>
<997x6 cell>
result{1,1}
'Genes' 'T0&T2' 'T2&T4' 'T4&T6' []
'YAR029W' 'P' 'P' 'P' 60
'YAR062W' 'PSO' 'SOP' 'PSO' 60
'YAR068W' 'PSO' 'POS' 'SOP' 60
'YBL095W' 'OSP' 'POS' 'PSO' 60
'YBL111C' 'SOP' 'POS' 'SOP' 60
Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 4일
that does not match what you posted in your question. it was about 4 columns
then the change will be
for k=1:length(result)
A=result{k};m=size(A,2)
A=A([1 ;find(cell2mat(cellfun(@(x) x>50,A(2:end,m),'uni',false)))+1],:)
out{k}=A
end
Azzi i think am frustating u a lot am sorry , i am not getting the result
i reduced the data as per
result =
{6x4 cell}
{5x4 cell}
{4x4 cell}
{3x4 cell}
and i tried or code
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 am getting answer ,but the size is altered such as
out=
{4x4 cell}
{5x4 cell}
{6x4 cell}
{3x4 cell}
please help my data consists of only 4 columns
Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 4일
no, try the corrected code without reducing anything
Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 4일
you said to only display some rows with condition, it's obvious sizes will change
kash
kash 2012년 9월 4일
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 2012년 9월 4일
편집: Azzi Abdelmalek 2012년 9월 4일
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]

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Calendar에 대해 자세히 알아보기

태그

질문:

2012년 9월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by