MatLab - Repeating a function
2 views (last 30 days)
Show older comments
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!!!
0 Comments
Answers (1)
Image Analyst
on 5 Apr 2013
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.
0 Comments
See Also
Categories
Find more on Data Import and Analysis 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!