Fetching data from another column

21 vues (au cours des 30 derniers jours)
Pat
Pat le 26 Août 2012
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 commentaires
Walter Roberson
Walter Roberson le 26 Août 2012
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 le 27 Août 2012
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

Connectez-vous pour commenter.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 27 Août 2012
Modifié(e) : Andrei Bobrov le 27 Août 2012
[~,~,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

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by