Inbuilt function that allows to count plus and minus signs of numbers?
조회 수: 2 (최근 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!