Manipulating matrix in particular columns
2 views (last 30 days)
Show older comments
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 Comment
per isakson
on 24 Jul 2012
Edited: per isakson
on 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.
Accepted Answer
Andrei Bobrov
on 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);
More Answers (0)
See Also
Categories
Find more on Genomics and Next Generation Sequencing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!