how can i count the values above a threshold of random data and represent on a graph of time vs. rate ?

1 view (last 30 days)
the # of occurrences (Rate) should be represented right in the middle of time slot. say 6 values above threshold within 0-1 second. 6 should be at .5s in the graph.
any help is appreciated thanks.
  10 Comments
Ana-Patricia Lopez
Ana-Patricia Lopez on 7 Jan 2014
i will post a new question for a new answer since this question was already answered with what I needed. unless you prefer to answer this question here, that is fine with me.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 18 Nov 2013
Apply histc() with evenly-distributed bins (of the desired time interval), applying it to your times. Use the two-output form of histc(), and then the second output will tell you the bin number. At that point,
counts = accumarray(bin_number(:), y(:) >= THRESHOLD);
This will give you the number of occurrences for each bin.
After that it just becomes a matter of text()'ing the counts into place at the mid-point of each interval.
  6 Comments
Ana-Patricia Lopez
Ana-Patricia Lopez on 30 Nov 2013
thanks for your reply @image analyst - really helpfull
When I proceed and run accumarray, I get this:
Error using accumarray Second input VAL must be a vector with one element for each row in SUBS, or a scalar.
I have tried plugging in y, Y, y_values and still get the same error:
counts=accumarray(ind(:), y_values(:));
I was not able to find a clear solution on the web. any thoughts?
-thanks
Ana-Patricia Lopez
Ana-Patricia Lopez on 28 Dec 2013
the histc() worked fine!
Im just trying to shift the counts right at midpoint of x ranges. any help is appreciated. thanks

Sign in to comment.

More Answers (0)

Categories

Find more on Polar Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!