MatLab - Repeating a function

1 次查看(过去 30 天)
jazzymat
jazzymat 2013-4-5
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
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.

类别

Help CenterFile Exchange 中查找有关 Data Import and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by