Split a matrix in two matrix according a criterion

Hello,
I have a text-matrix :
genotype =
'WT'
'WT'
...
'KO'
'KO'
...
(format x*1 cell)
And, a number-matrix :
var =
60
80
..
50
60
..
(format : x*1 double)
It is good for using anova1 :
r = anova1(var, genotype)
But, for further analysis and plotting, i need another format :
wt_ var =
60
80
...
and
ko_var =
50
60
...
How can i generate wt_var and ko_var using genotype and var ?
Thanks !

답변 (1개)

Jos (10584)
Jos (10584) 2015년 2월 28일
% sample data
G = {'wt','wt','ko','ko','wt'}
V = [10 20 30 40 50]
% transform G into numbers, there are other ways
[tf, idx] = ismember(G,{'wt','ko'})
% select
V_wt = V(idx==1)
V_ko = V(idx==2)

댓글 수: 1

Thank you for your answer :-) I do not know if i understand, but it seems to not do exactly what i ma looking for.
It is more like this :
genotype =
'WT'
'KO'
'WT'
'KO'
var =
1
2
4
5
Another way to see it :
'WT' 1
'KO' 2
'WT' 4
'KO' 5
After :
wt_var =
1
4
ko_var =
2
5

댓글을 달려면 로그인하십시오.

카테고리

질문:

2015년 2월 28일

댓글:

2015년 2월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by