Inbuilt function that allows to count plus and minus signs of numbers?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2013-1-16
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!