Help with Monte Carlo sim?

1 次查看(过去 30 天)
Im messing around with the montecarlo function for integration and ran into a problem. The y bounds are between x^2 and x^3 and x are between 0 and 1. Heres the code I have so far but can't figure out how to deal with the y bounds.
N=1000; Landed=0;
for i=1:N x=rand()*1; y=rand()* Landed=Landed+1 end disp('Calculated Area Size:') area=

采纳的回答

Image Analyst
Image Analyst 2018-7-23
That code won't even run. Even if it did, your x and y are just rand() which goes between 0 and 1. The y bounds have nothing at all to do with x, x^2 or x^3, but since they all use rand, everything will be between 0 and 1. If you want some higher value, multiply rand() by some amplification factor.
I'm attaching my Monte Carlo demos, for what it's worth.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by