Fetching data from another column

2 次查看(过去 30 天)
I have 2 data as below
A={
'Genes' 'T0&T2' 'T1&T3' 'T2&T4' 'T3&T5' 'T4&T6'
'YAR029W' 'dd' 'uu' 'dd' 'uu' 'du'
'YBL095W' 'du' 'ud' 'ud' 'du' 'du'
'YBL111C' 'uu' 'uu' 'ud' 'ud' 'du'
'YBL113C' 'uu' 'uu' 'uu' 'ud' 'ud'
'YBR096W' 'uu' 'uu' 'ud' 'ud' 'dd'
'YBR138C' 'ud' 'ud' 'ud' 'du' 'du' }
B={
'Genes' 'T0&T2' 'T1&T3' 'T2&T4' 'T3&T5' 'T4&T6'
'YAR029W' 'd' 'u' 'd' 'u' 'd'
'YBL095W' 'd' 'u' 'u' 'd' 'd'
'YBL111C' 'u' 'u' 'u' 'u' 'd'
'YBL113C' 'u' 'u' 'u' 'u' 'u'
'YBR096W' 'u' 'u' 'u' 'u' 'd'
'YBR138C' 'u' 'u' 'u' 'd' 'd' }
i want to fetch the value from B as compared to A as
gene1(or any variable)=
'Genes' 'T0&T2' 'T1&T3' 'T2&T4' 'T3&T5' 'T4&T6'
'YAR029W' 'd' 'u' 'd' 'u' 'd'
'YBL095W' 'du' 'ud' 'ud' 'du' 'du'
'YBL111C' 'uu' 'uu' 'ud' 'ud' 'du'
'YBL113C' 'uu' 'uu' 'uu' 'ud' 'ud'
'YBR096W' 'uu' 'uu' 'ud' 'ud' 'dd'
'YBR138C' 'ud' 'ud' 'ud' 'du' 'du'
gene2(or any variable)=
'Genes' 'T0&T2' 'T1&T3' 'T2&T4' 'T3&T5' 'T4&T6'
'YBL095W' 'd' 'u' 'u' 'd' 'd'
'YBL111C' 'uu' 'uu' 'ud' 'ud' 'du'
'YBL113C' 'uu' 'uu' 'uu' 'ud' 'ud'
'YBR096W' 'uu' 'uu' 'ud' 'ud' 'dd'
'YBR138C' 'ud' 'ud' 'ud' 'du' 'du'
as lile this i need to do for all genes in variable B please help
  8 个评论
Walter Roberson
Walter Roberson 2012-8-26
ismember() will not help you with your difficulty of wanting to create variable names dynamically, wanting to create first gene1, then gene2, and so on.
Pat
Pat 2012-8-27
walter can u tell wats the solution ,how to solve it please, if it not possible to create variables name its ok ,the output can be stores in any variable as i stated above,i need to perform that output ,please help

请先登录,再进行评论。

采纳的回答

Andrei Bobrov
Andrei Bobrov 2012-8-27
编辑:Andrei Bobrov 2012-8-27
[~,~,c] = unique(A(2:end,1));
gene = cellfun(@(x,y)[A(1,:);x;A([false,y],:)],num2cell(B(2:end,:),2),num2cell(bsxfun(@lt,c,c'),2),'un',0);
OR
n = size(A,1);
gene = cell(n-1,1)
for jj = 1:n-1
gene{jj} = [A(1,:);B(jj+1,:);A(jj+2:end,:)];
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genomics and Next Generation Sequencing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by