Calculate a matrix based on value from another matrices
1 回表示 (過去 30 日間)
古いコメントを表示
Hi. I want to calculate new value in matrix C and based on conditions from value of matrix P and R.
R=
[1 -0.136 0.036
-0.136 1 -0.327
0.036 -0.32 1]
P=
[1 1.02385610592401e-07 0.155888059376484
1.02385610592401e-07 1 5.36959056693074e-39
0.155888059376484 5.36959056693074e-39 1]
significant = zeros(size(P)) ;
significant(P<0.05) = 1 ;
positives=zeros(size(R));
positives(R>0) = 1 ;
I want to calculate C like this,
-1- In same row and column, I want to make value 1, if both matrices is one, and else will become zero.
Can you help me? Thanks
回答 (1 件)
Andrei Bobrov
2017 年 7 月 6 日
編集済み: Andrei Bobrov
2017 年 7 月 6 日
n = size(P,2);
pp = P < .05;
C = sum(pp,2)/n;
[i1,j1] = find(pp.*(1:n));
E = cellfun(@(x)strjoin(x,','),accumarray(i1,j1,[],@(x){sort(D(x))}),'un',0);
At new edition of question
R = [1 -0.136 0.036
-0.136 1 -0.327
0.036 -0.32 1];
P = [1 1.02385610592401e-07 0.155888059376484
1.02385610592401e-07 1 5.36959056693074e-39
0.155888059376484 5.36959056693074e-39 1];
C = P < 0.05 & R > 0
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!