How can I choose an element from a vector according to its probability ?
Show older comments
I want to select an angle according to the probability. I executed the code below its show me the only FIRST option (only 10 even when I change the probability value its show me the same option). Thank in advance for any help
t=0.1;Ang_1 = [10 20 30 45 80];% this vector of options
for i:1:1
prob = (exp((1/t)*1.2*10^-5))./(exp((1/t)*1.2*10^-4)) % this is probability could be changable each eteration
select = Ang_1(find(rand<cumsum(prob),1)) % select angle according to "prob"
end
Accepted Answer
More Answers (0)
Categories
Find more on Probability Density Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!