Objectmix
Tags Register Mark Forums Read

idl loops urgent! : Idl-pvwave

This is a discussion on idl loops urgent! within the Idl-pvwave forums in Programming Languages category; Hi I have an array which is [15,13,2191] filled with 1's and 0's. I need to find when there are four or more consecutive events in this array ie when there are four or more consecutive 1's in the array. I have made a set of loop for j=0,14 do begin for z=0,12 do begin for i=0,2190 do begin if array(j,z,i) eq 1 then begin number_in_row=number_in_row+1 endif else begin number_in_row=0 endelse if number_in_row ge 4 then begin event=event+1 endif endfor endfor endfor index=intarr(2191) index(*)=0 number=0 for j=0,14 do begin for z=0,12 do begin for i=0,2190 do begin if array(j,z,i) eq ...


Object Mix > Programming Languages > Idl-pvwave > idl loops urgent!

Reply

 

LinkBack Thread Tools
  #1  
Old 06-09-2009, 04:31 AM
Junior Member
 
Join Date: May 2009
Posts: 2
confusedgirl is on a distinguished road
Exclamation idl loops urgent!

Hi
I have an array which is [15,13,2191] filled with 1's and 0's. I need to find when there are four or more consecutive events in this array ie when there are four or more consecutive 1's in the array. I have made a set of loop

for j=0,14 do begin
for z=0,12 do begin
for i=0,2190 do begin
if array(j,z,i) eq 1 then begin
number_in_row=number_in_row+1
endif else begin
number_in_row=0
endelse
if number_in_row ge 4 then begin
event=event+1
endif
endfor
endfor
endfor

index=intarr(2191) index(*)=0
number=0
for j=0,14 do begin
for z=0,12 do begin
for i=0,2190 do begin
if array(j,z,i) eq 1 then begin
if array(j,z,i-1) eq 0 then begin
index(i)=number
number=number+1
endif else begin
index(i)=index(i-1)
endelse
endif
endfor
endfor
endfor

WHen I run this it gives my a sensible number of events approx 110. However when I do help,number I get over 5000 values and the groups of 1's are not given a single number nor are they number consecutively?!?!?!?
When I do print,histogram(index) I get an array of 0,1,2..s but if I do print,WHERE(histogram(index) ge 4) I just get zero.

Could someone please tell me if there ifs an easier way to do this or if there is a way of fixing this code.

thanks
endfor
endfor
Reply With Quote
Reply

Thread Tools


Similar Threads

Thread Thread Starter Forum Replies Last Post
Re: i am having a problem with while loops, i have two while loops,i have a random number generator inside the "inside" loop and iwant to read an array outside the "outer" loop. usenet labview 0 02-12-2008 01:40 PM
Loop with 2 loops. Start 2 'inside' loops at different time. usenet labview 2 12-03-2007 06:10 PM
for-loops that inherit the number of iterations from previousfor-loops. usenet labview 0 09-12-2007 11:10 AM
Re: Exchange 2000 IS Mailbox store cannot mount - URGENT URGENT URGENT usenet Microsoft Exchange 3 01-17-2006 09:20 AM
Exchange 2000 IS Mailbox store cannot mount - URGENT URGENT URGENT usenet Microsoft Exchange 0 11-16-2005 07:45 AM


All times are GMT -5. The time now is 10:59 PM.