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
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.
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File 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!