フィルターのクリア

Inbuilt function that allows to count plus and minus signs of numbers?

2 ビュー (過去 30 日間)
Lily
Lily 2013 年 1 月 16 日
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??

採用された回答

Walter Roberson
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 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by