How to count negative and postive values in a matrix?

92 views (last 30 days)
Sir, how can i get the mean and standard deviation and total numbers of negative values and similarly for positive values in a matrix A(i,j).Please help

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 5 Aug 2015
s=sign(A)
ipositif=sum(s(:)==1)
inegatif=sum(s(:)==-1)
  4 Comments
Torsten
Torsten on 5 Aug 2015
Edited: Torsten on 5 Aug 2015
m=mean(A(s==-1))
st=std(A(s==-1))
Best wishes
Torsten.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!