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

Home » Public Forums » archive » Re: The IDL way: Find last non-zero value
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: The IDL way: Find last non-zero value [message #67744 is a reply to message #67737] Sun, 23 August 2009 20:39 Go to previous messageGo to previous message
cgguido is currently offline  cgguido
Messages: 195
Registered: August 2005
Senior Member
Another option - given that your array contains only positive numbers,
I thought total(array, 1, /cumulative) could be handy:

array=[ [1,2, 0, 1, 0, 0],$
[0, 0, 3,4, 1, 0],$
[1, 5,6, 0, 0, 0],$
[0,0,0,0,0,0], $
[1, 0,0,0,0,0] ]


tc=total(array, 1, /cumulative)
blah=max(tc, dim=1, w)
result=(array_indices(tc,w))[0,*]

t=total(array, 1)
result[where(t eq 0)]=-1

Gianguido
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Histogram Too Many Array Elements
Next Topic: Integer - decimal help

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

Current Time: Sat Oct 11 09:03:22 PDT 2025

Total time taken to generate the page: 0.96346 seconds