Calculating number of elements of a vector greater or equal than elements of other vector
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Marco Lingua
am 19 Jan. 2021
Kommentiert: Marco Lingua
am 19 Jan. 2021
Hello everyone, it's my first post here. I need some help for my code: i've got a 1 x 10.000 array which contains the results of a Monte Carlo simulation and a 1x2000 array which contains certain values in ascending order (losses). I would like to run a script which counts for each loss how many values in the MC array are greater or equal and creates a third vector (same dimensions of the second, so 1x2000) filles with th numbers of "excedeances".
Thanks for your support!
0 Kommentare
Akzeptierte Antwort
J. Alex Lee
am 19 Jan. 2021
R = rand(1,10000);
losses = sort(rand(1,2000));
for i = numel(losses):-1:1
counts(i) = sum(R >= losses(i))
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!