Edit:Error in counting uinque values

1 view (last 30 days)
I have values xres=
<1001x3 cell>
<1000x3 cell>
<999x3 cell>
xres{1,1}
'YAR029W' 'd' []
'YAR062W' 'du' 60
'YAR068W' 'du' 60
'YBL095W' 'uu' 60
'YBR028C' 'uu' 60
'YBR074W' 'uu' 60
'YBR138C' 'du' 60
'YBR241C' 'du' 60
i used code
x=rfinalll;
for pp=1:numel(x)
[q,q,q] = unique(x{pp}(2,2:end);
instances = histc(x,q);
x{pp}=x{jj}[values instances];
xres1{pp}=x{jj}[rfinall ;x]
i ecpected result as
xres{1,1}
'YAR029W' 'd' []
'YAR062W' 'du' 60
'YAR068W' 'du' 60
'YBL095W' 'uu' 60
'YBR028C' 'uu' 60
'YBR074W' 'uu' 60
'YBR138C' 'du' 60
'YBR241C' 'du' 60
'' 'var' 'occ'
'' 'du' 2
'' 'uu' 3
'' 'du' 2
but getting error i need some space between rfinall and x

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 5 Sep 2012
The initial data xres
xres={{
'YAR029W' 'd' []
'YAR062W' 'du' 60
'YAR068W' 'du' 60
'YBL095W' 'uu' 60
'YBR028C' 'uu' 60
'YBR074W' 'uu' 60
'YBR138C' 'du' 60
'YBR241C' 'du' 60};
{
'YAR029W' 'd' []
'YAR062W' 'du' 60
'YAR068W' 'du' 60
'YBL095W' 'uu' 60
'YBR028C' 'ud' 60
'YBR074W' 'uu' 60
'YBR138C' 'du' 60
}}
x = xres;
z={''};
for jj = 1:numel(x)
q = x{jj};
[a,b,b] = unique(q(2:end,2));
t = [true;diff(b)~=0];
t2 = cumsum(t);
out = [z(ones(nnz(t),1)),a(b(t)),num2cell(histc(t2,1:max(t2)))];
x{jj} = [q;{'' '' '';'' 'var' 'occ'};out];
end

More Answers (0)

Community Treasure Hunt

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

Start Hunting!