Averaging positive and negative values seperately for each array in a matrix
Mostrar comentarios más antiguos
Hi all,
I have a 40X1000 matrix and I want to average positive and negative values seperately for each array.
Lets say A=[0 2 2 -1 -7; 0 -1 -3 -2 6], I want an output file like output=[4 -4; 6 -2].
Does any of you know how to solve this ?
Many thanks
1 comentario
Matt J
el 9 de Dic. de 2014
Based on the A shown, I think the output should be
output =
2 -4
6 -2
Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 9 de Dic. de 2014
A=[0 2 2 -1 -7; 0 -1 -3 -2 6]
x1=[arrayfun(@(x) mean(A(x,A(x,:)>0)),(1:size(A,1))') arrayfun(@(x) mean(A(x,A(x,:)<0)),(1:size(A,1))')]
1 comentario
PIRIL
el 10 de Dic. de 2014
Categorías
Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!