Using "rand" to randomize percent probability between two numbers

11 ビュー (過去 30 日間)
lauuser1
lauuser1 2016 年 4 月 10 日
回答済み: Image Analyst 2016 年 4 月 10 日
How would you write a code to do these probabilities? These probabilities are all related, so for example it would mean one helicopter has all of these probabilities to rise or fall a certain meter.
50% probability between 0m to 25m
10% probability between 25m to 50m.
5% probability between 50m to 75m.
20% probability between 0m to 50m.
10% probability between 50m to 150m.
5% probability between 150m to 200m.
There is an equal probability of any value between the two values.

採用された回答

Image Analyst
Image Analyst 2016 年 4 月 10 日
Do you mean like this:
r = rand;
if r < .5
% 50% probability between 0m to 25m
elseif r < 0.6
% 10% probability between 25m to 50m.
elseif r < 0.65
% 5% probability between 50m to 75m.
elseif r < 0.85
% 20% probability between 0m to 50m.
elseif r < 0.95
% 10% probability between 50m to 150m.
else
% 5% probability between 150m to 200m.
end
You get a random number and then test it. You will go into the respective blocks of the "if" with the designated probabilities. Then inside the block you can do whatever you want, such as set the altitude or change in altitude or whatever.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHypothesis Tests についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by