<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Mar 1, 2013 at 7:00 AM, Ulrich Eckhardt <span dir="ltr"><<a href="mailto:ulrich.eckhardt@dominolaser.com" target="_blank">ulrich.eckhardt@dominolaser.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am 01.03.2013 09:59, schrieb Isaac Won:<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
try to make my triple nested loop working. My code would be:<br>
c = 4<br>
</blockquote></div>
[...]<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
while c <24:<br>
c = c + 1<br>
</blockquote>
<br></div>
This is bad style and you shouldn't do that in python. The question that comes up for me is whether something else is modifying "c" in that loop, but I think the answer is "no". For that reason, use Python's way:<br>
<br>
for c in range(5, 25):<br>
...<br>
<br>
That way it is also clear that the first value in the loop is 5, while the initial "c = 4" seems to suggest something different. Also, the last value is 24, not 23.<div class="im"><br>
<br>
<br></div></blockquote><div>I concur with Uli, and add the following thoughts: What is going on with [y]? Is this really a list? So what is y1 + y1 + [y] doing? <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im">
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
while d <335:<br>
d = d + 1<br>
y = fpsd[d]<br>
y1 = y1 + [y]<br>
m = np.mean(y1)<br>
m1 = m1 + [m]<br>
</blockquote>
<br></div></blockquote><div>In your outer loop you initialize these values each pass:<br><br> dt = 900.0 #Time step (seconds)<br>
fs = 1./dt #Sampling frequency<br>
<br></div><div>This should me moved out of the loop since nothing changes with dt or fs<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"></div>
Apart from the wrong indention (don't mix tabs and spaces, see PEP 8!) and the that "d in range(336)" is better style, you don't start with an empty "y1", except on the first iteration of the outer loop.<br>
<br>
I'm not really sure if that answers your problem. In any case, please drop everything not necessary to demostrate the problem before posting. This makes it easier to see what is going wrong both for you and others. Also make sure that others can actually run the code.<br>
<br>
<br>
Greetings from Hamburg!<br>
<br>
Uli<span class=""><font color="#888888"><br>
<br>
<br>
<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr"><div>Joel Goldstick<br></div><a href="http://joelgoldstick.com" target="_blank">http://joelgoldstick.com</a><br></div>
</div></div>