Finding the mean of all negative elements in the first column of a matrix?
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Star Strider
on 11 Jan 2015
This works:
Xm1 = mean(X(X(:,1)<0,1));
4 Comments
Star Strider
on 21 Jan 2015
My pleasure!
Thank your for your extra effort in order to Accept my Answer!
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements 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!