how to create new cumulative frequency array from two existing arrays

조회 수: 1 (최근 30일)
BigWaffle
BigWaffle 2021년 4월 29일
답변: David Goodmanson 2021년 4월 29일
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