Inbuilt function that allows to count plus and minus signs of numbers?
1 view (last 30 days)
Show older comments
Hi Is there a function inbuilt into MATLAB that allows you to count plus and minus signs of numbers? F.ex. if your data was:
data = [ -0.2 -0.1 0 1.1 2.4 0.5 -0.8 -0.9];
if would count in signs: - - + + + + - -
Is it possible??
0 Comments
Accepted Answer
Walter Roberson
on 16 Jan 2013
There is no inbuilt function. You can use sign() to determine the sign as -1 0 or +1 but then you would still need to do the counting. So you might as well use:
numnonneg = sum(data >= 0);
numneg = length(data) - numnonneg;
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!