Calculate a matrix based on value from another matrices
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
2 Kommentare
Antworten (1)
Andrei Bobrov
am 6 Jul. 2017
Bearbeitet: Andrei Bobrov
am 6 Jul. 2017
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 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!