SHARE
TWEET

Untitled

a guest May 24th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function shit = ellipseMC
  2.  
  3. f1 = @(x,y) x.^2/16 + y.^2 - 1;
  4. fimplicit(f1)
  5. hold on
  6.  
  7. Xrand = 8.*rand(10000,1) -4;
  8. Yrand = 2.*rand(10000,1) -1;
  9.  
  10. Nin = 0;
  11. Nout = 0;
  12.  
  13. plot(Xrand,Yrand,'.');
  14.  
  15. for ii = 1:10000
  16.     if ((Xrand(ii)^2/16 + Yrand(ii)^2 <= 1))
  17.         Nin = Nin + 1;
  18.     else
  19.         Nout = Nout + 1;
  20.     end
  21. end
  22.  
  23. disp(Nin/Nout);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top