how to create new cumulative frequency array from two existing arrays

1 次查看(过去 30 天)
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);

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by