I am using Matlab, and I have a 1×200 vector of numbers.
I need to assign a “score” to the set of numbers by following these rules:
- If there are 2 or 3 or 4 consecutive positive numbers, then 0.5 points
- If there are five or more consecutive positive numbers, then 1.0 points
- If there isn’t any consecutive positive number, for example: 0 0 0 6 0 0, then 0.0 point. (ignore it, consider that positive number as zero)
- If there is only one zero in the middle of a run of positive integers, then ignore that zero (consider it as a positive integer)
- If there are two or more consecutive zeroes, that breaks the run of consecutive positive numbers.
Example: 30 43 54 0 0 0 41 54 14 10 1 0 0 0 0 32 41 98 12 0 0 0 (2.0 points total)
At the end, there should be a tally of the points.
Are there any useful functions for this type of problem?
This is based on my understanding of the question, as noted in my question above. I’ve “unsuppressed” all output, so you can see what’s going on.