MatLab - Repeating a function

Hi
I'm relatively new to MatLab & I'm really struggling!
I have written a function which simulates a raffle and calculates the prize money you may expect to win with one play of the raffle. However, this is a weekly raffle & I wish to work out how much you could expect to win if you played in the raffle once a week for a year, so how do i repeat the whole function? & calculate the total prize money?
Any help would be greatly appreciated!!!

回答 (1 件)

Image Analyst
Image Analyst 2013 年 4 月 5 日

2 投票

You can have two functions in one m-file, test_raffle_simulation.m:
function test_raffle_simulation
for k = 1 : 1000000 % a million trials
outputs = raffle_Simulation(inputs);
end
function outputs = raffle_simulation(inputs)
% code
Of course you can send in input arguments and receive output arguments of whatever type and number you want.

カテゴリ

ヘルプ センター および File ExchangeData Import and Analysis についてさらに検索

質問済み:

2013 年 4 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by