comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » problem in finding average for every 100 points in a data set.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: problem in finding average for every 100 points in a data set. [message #87422 is a reply to message #87418] Fri, 31 January 2014 20:34 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Friday, January 31, 2014 9:26:48 PM UTC-5, arsood wrote:
> Can please anybody tell me is my code correct and how can I print all non zero values in first place??

This code:
> bb(i) = mean(B(i:i+200))
is incorrect because you are averaging 201 points, not 100 points. Also, the variable I increases by 100 every step, so you only put valid data in B[] every 100th point.

If you are going to do it with a loop, then keep track of input array and output array separately, like this.

i = 0L
j = 0L
while i LT (n-100) do begin
bb(j) = mean(b(i:i+99))
i = i + 100 ;; Advance to next block in B
j = j + 1 ;; Advance to next position in BB
endwhile
n_output = j
print, bb(0:n_output-1)

CM
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: cgplotting points with error bars
Next Topic: extra lines in colorbar

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:10:30 PDT 2025

Total time taken to generate the page: 0.00553 seconds