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!