Calculate a matrix based on value from another matrices

1 visualización (últimos 30 días)
yue ishida
yue ishida el 6 de Jul. de 2017
Editada: Andrei Bobrov el 6 de Jul. de 2017
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 comentarios
yue ishida
yue ishida el 6 de Jul. de 2017
I already change the question, actually I forgot to edit when I've been out for a while.

Iniciar sesión para comentar.

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 6 de Jul. de 2017
Editada: Andrei Bobrov el 6 de Jul. de 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

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by