how to create new cumulative frequency array from two existing arrays

1 view (last 30 days)
I would like to make an array from logic between two other arrays
So for code below when i want to make an array using a while loop for when logic Y <= v is fulfilled then new array being created will give me cumulative frequency.
for example:
Y= [ 5 5 3 4 5]
v = [ 4 3 3 4 6]
for Y <= X new array should be:
CumFreq = [ 0 0 1 2 3]
so frequency keeps compounding.
below are the two arrays i am trying to perform while loop on with Y<=v
mu = 50
sigma = 10
Y = normrnd(mu, sigma, 1,1000);
v = linspace(1,1000, 1000);

Answers (1)

David Goodmanson
David Goodmanson on 29 Apr 2021
Hi BW,
mu = 50
sigma = 10
Y = normrnd(mu, sigma, 1,1000);
v = linspace(1,1000, 1000);
a = cumsum(Y<=v)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!