MatLab - Repeating a function
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Image Analyst
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!