Code Comments
Programming Forum and web based access to our favorite programming groups.Hello group
Is there a function that can help in doing the task below or do I need
to write something up?
I need to get the index of the relative “local” maximums and minimums in
a sequence or real numbers.
Say a={5,4,2,2,2,2,2,7}
The index I need is the one belong to the first occurrence of the number
2, which is the third number in the above sequence for a local minimum.
Say a={5,8,2,1}
The index I need is the one belongs to the number 8, which is the second
in the sequence for the local maximum.
Say a={5,4,2,2,2,7,2}
The index I need is the ones belong to the first 2 and then the 7. as an
index of local minimum and maximum respectively.
Thanks
Post Follow-up to this message
>
> Say a={5,4,2,2,2,2,2,7}
> The index I need is the one belong to the first occurrence of the number
> 2, which is the third number in the above sequence for a local minimum.
>
index = minloc(a)
> Say a={5,8,2,1}
> The index I need is the one belongs to the number 8, which is the second
> in the sequence for the local maximum.
>
index = maxloc(a)
> Say a={5,4,2,2,2,7,2}
> The index I need is the ones belong to the first 2 and then the 7. as an
> index of local minimum and maximum respectively.
>
index_min = minloc(a)
index_max = maxloc(a)
Regards,
Mike Metcalf
Post Follow-up to this message"Michael Metcalf" <michaelmetcalf@compuserve.com> wrote in message news:d7veje$u19$04$1@news.t-online.com... > index = minloc(a) And the answer to his next question is: index = minloc(a,1) -- write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, & 6.0134700243160014d-154/),(/'x'/)); end
Post Follow-up to this message"James Van Buskirk" <not_valid@comcast.net> wrote in message news:BcCdnXNbc8hw3z7fRVn-jQ@comcast.com... > "Michael Metcalf" <michaelmetcalf@compuserve.com> wrote in message > news:d7veje$u19$04$1@news.t-online.com... > > > And the answer to his next question is: > > index = minloc(a,1) > Whoops, sure thing. Mike Metcalf
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.