how to create new cumulative frequency array from two existing arrays

1 visualización (últimos 30 días)
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);

Respuestas (1)

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

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by