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!