MatLab - Repeating a function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Image Analyst
el 5 de Abr. de 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 comentarios
Ver también
Categorías
Más información sobre Data Import and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!