Manipulating matrix in particular columns

4 Ansichten (letzte 30 Tage)
Pat
Pat am 24 Jul. 2012
I have variables
final_result = {
'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' }
final =
'YAR029W' 'd' [] 'd' [] 'd'
'YBL095W' 'd' [] [] 'd' 'd'
'YBL111C' 'u' 'u' 'u' 'u' []
'YBL113C' 'u' 'u' 'u' 'u' 'u'
'YBR096W' 'u' 'u' 'u' 'u' []
'YBR138C' 'd' [] [] 'd' 'd'
I need to fetch only the corresponding column from final_result with respect from final [] must be omitted
I need output as
final1=
'Genes' 'T0&T2' 'T2&T4' 'T4&T6'
'YAR029W' 'dd' 'dd' 'du'
'YBL095W' 'du' 'ud' 'du'
'YBL111C' 'uu' 'ud' 'du'
'YBL113C' 'uu' 'uu' 'ud'
'YBR096W' 'uu' 'ud' 'dd'
'YBR138C' 'ud' 'ud' 'du'
final2=
'Genes' 'T0&T2' 'T3&T5' 'T4&T6'
'YBL095W' 'du' 'du' 'du'
'YBL111C' 'uu' 'ud' 'du'
'YBL113C' 'uu' 'ud' 'ud'
'YBR096W' 'uu' 'ud' 'dd'
'YBR138C' 'ud' 'du' 'du'
; ; ; final5
'Genes' 'T0&T2' 'T1&T3' 'T2&T4' 'T3&T5'
'YBR096W' 'uu' 'uu' 'ud' 'ud'
'YBR138C' 'ud' 'ud' 'ud' 'du'
please help
  1 Kommentar
per isakson
per isakson am 24 Jul. 2012
Bearbeitet: per isakson am 24 Jul. 2012
Put a bit more effort into the description of the problem! Remember you asking us to work for free for you.
The process of formulating the problem might help you find the solution.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 24 Jul. 2012
final_result = {
'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' };
final = {
'YAR029W' 'd' [] 'd' [] 'd'
'YBL095W' 'd' [] [] 'd' 'd'
'YBL111C' 'u' 'u' 'u' 'u' []
'YBL113C' 'u' 'u' 'u' 'u' 'u'
'YBR096W' 'u' 'u' 'u' 'u' []
'YBR138C' 'd' [] [] 'd' 'd'};
n = ~cellfun(@isempty,final(:,2:end));
fnl = arrayfun(@(x)final_result([1,x+1:end],[true,n(x,:)]),(1:size(n,1))','un',0);

Weitere Antworten (0)

Kategorien

Mehr zu Sparse Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by