Sum specific colums based on a criteria

Dear all, I have a column matrix A and an nxn matrix B. I have been able to estimate the correlation coefficient (R) between the constant column matrix A and each column vector in matrix B using corr(A,B). However, I am finding difficulties in summing only columns with their R=>0.2, while ignoring columns with R<0.2. I will be very grateful for the assistance.

 Respuesta aceptada

madhan ravi
madhan ravi el 18 de Mayo de 2019
Editada: madhan ravi el 18 de Mayo de 2019
sum(R(:,any(R>=.2)))

3 comentarios

Albert Buabeng
Albert Buabeng el 19 de Mayo de 2019
Thanks for your quick response, this code sums the correlation coefficients instead of the nxn matrix B.
madhan ravi
madhan ravi el 19 de Mayo de 2019
Editada: madhan ravi el 19 de Mayo de 2019
sum(B(:,any(R>=.2))) % syms B according to R satisfying the condition
Albert Buabeng
Albert Buabeng el 19 de Mayo de 2019
It's working just as expected, thank you very much. You are a live saver.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Centro de ayuda y File Exchange.

Productos

Versión

R2018a

Etiquetas

Preguntada:

el 18 de Mayo de 2019

Comentada:

el 19 de Mayo de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by