0

I am trying to get the number of positive numbers in a matrix. The matrix has numbers such as these:

35.0558   30.1323  -24.0061   -7.0385  -83.3891

I cannot use a loop and I approached so I use a regexp and if its positive it should give 1 otherwise 0 and the sum up the 1s and get the total number, but currently at the moment I am getting only [] ....

Here is what I have so far:

X = regexp(cellstr(num2str(reshape(int8(rint),1,[])'))','^[1-9][0-9]*$')

any ideas what's going wrong ? I think the regexp is alright...

toolic
  • 57,801
  • 17
  • 75
  • 117
Unsparing
  • 6,985
  • 2
  • 17
  • 33
  • `sum(A(:) > 0)` Or maybe I misinterpreter your question.... – usεr11852 Oct 26 '15 at 20:33
  • assuming that this regex function returns an array with the 0 index being the entire string and then the matched groups: `/^(?:[^-](\d+)[\s\S]*?)+/` and count the array and subtract 2 from the total count – x13 Oct 28 '15 at 13:17

0 Answers0