Manipulating matrix in particular columns

4 visualizzazioni (ultimi 30 giorni)
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 Commento
per isakson
per isakson il 24 Lug 2012
Modificato: per isakson il 24 Lug 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.

Accedi per commentare.

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 24 Lug 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);

Più risposte (0)

Categorie

Scopri di più su Sparse Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by