Summing up the answers in for loop that meets criteria
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Cside
el 15 de Feb. de 2020
Editada: Gifari Zulkarnaen
el 15 de Feb. de 2020
I have this code and would like to find out of the 220 loops, how many of the corrcoef end answer fit the criteria of P<0.05 and r >0.3. I want the the loop to reflect the sum of all the corrcoef values that fit the criteria, and not for every loop. Thank you for the help!
for n = 1:220
pfc = A(combi(n,1),1:270);
fef = B(combi(n,2),1:270);
zpfc = zscore(pfc);
zfef = zscore(fef);
[R,P] = corrcoef(zpfc,zfef);
sum(P(2,1) <0.05 & R (2,1) > 0.3); %%(2,1) being the position of the value in the 2x2 corrcoef output
end
0 comentarios
Respuesta aceptada
Gifari Zulkarnaen
el 15 de Feb. de 2020
Editada: Gifari Zulkarnaen
el 15 de Feb. de 2020
Try this
criteria=zeros(220,1)
for n = 1:220
pfc = A(combi(n,1),1:270);
fef = B(combi(n,2),1:270);
zpfc = zscore(pfc);
zfef = zscore(fef);
[R,P] = corrcoef(zpfc,zfef);
criteria(n) = P(2,1)<0.05 & R(2,1)>0.3; %%(2,1) being the position of the value in the 2x2 corrcoef output
end
your_answer = sum(criteria);
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!