Re: I need help on Number Based Repetition
- From: Tuong <tuong_ng89@xxxxxxxxx>
- Date: Wed, 03 Oct 2007 12:20:53 EDT
wow, that's a lot clearer now, but the bad news is: I turned in the HW 15 minutes ago :(
the good news is, I have made a change in my program after much unnecessary thinking, here it is (it's somewhat similar to yours but I think it's actually shorter, and the value actually comes out to be 3.14xxx when I input 1,000,000 as the variable n):
function p = mypi( n )
o = 0;
for k = 1:n
x = rand;
y = rand;
l = sqrt(rand^2 + rand^2);
if l <= 1
o = o + 1/n;
end
p = 4*o;
end
.
- References:
- Re: I need help on Number Based Repetition
- From: Randy Poe
- Re: I need help on Number Based Repetition
- Prev by Date: bwlabel gone wrong??
- Next by Date: Re: How to count number of spikes in a signal (related to noise)
- Previous by thread: Re: I need help on Number Based Repetition
- Next by thread: Combining data from different excel spreadsheets
- Index(es):
Relevant Pages
|