Finding the mean of all negative elements in the first column of a matrix?

1 view (last 30 days)
Hello my friends! Happy New Year!!
This is what got so far:
X=[-4 8 -2 -6 9;
1 2 7 3 -5;
-9 -5 -3 4 5]
if(X<0)]
M=Mean(X)
end;
I'm new to Matlab, so sorry if it's easy to answer. Many thanks in advance

Accepted Answer

Star Strider
Star Strider on 11 Jan 2015
This works:
Xm1 = mean(X(X(:,1)<0,1));
  4 Comments
Micheal
Micheal on 21 Jan 2015
Hello my comrads! I accept answer, could not find button until now. Thank you Star Strider for your help!!

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!