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

Home » Public Forums » archive » Array containing maximum values for two arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Array containing maximum values for two arrays [message #86912] Thu, 12 December 2013 09:17 Go to next message
joellama is currently offline  joellama
Messages: 8
Registered: July 2013
Junior Member
Hi,

I am trying to figure out how to take two arrays and make a new array with each value is the maximum value of each of the sub elements of the two arrays, i.e.

a = [5, 6, 7]
b = [3, 8, 4]

then the resultant vector would be
c= [5, 8, 7]

Ideally I would obviously like to do this without a loop!

Any help would be really appreciated
Re: Array containing maximum values for two arrays [message #86913 is a reply to message #86912] Thu, 12 December 2013 09:21 Go to previous messageGo to next message
joellama is currently offline  joellama
Messages: 8
Registered: July 2013
Junior Member
On Thursday, December 12, 2013 5:17:46 PM UTC, joel...@gmail.com wrote:
> Hi,
>
>
>
> I am trying to figure out how to take two arrays and make a new array with each value is the maximum value of each of the sub elements of the two arrays, i.e.
>
>
>
> a = [5, 6, 7]
>
> b = [3, 8, 4]
>
>
>
> then the resultant vector would be
>
> c= [5, 8, 7]
>
>
>
> Ideally I would obviously like to do this without a loop!
>
>
>
> Any help would be really appreciated

Apologies, i've just realised that max(array, dimension=2) will do what i'm after.
Re: Array containing maximum values for two arrays [message #86917 is a reply to message #86913] Thu, 12 December 2013 11:28 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
On Thursday, December 12, 2013 11:21:09 AM UTC-6, joel...@gmail.com wrote:
>
> Apologies, i've just realised that max(array, dimension=2) will do what i'm after.

Well, you could do that, assuming you're concatenating your two 1D arrays in to an nx2 array. But, a more efficient way is to use the maximum operator:

c = a > b
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How can I send commands from Java application to IDL application?
Next Topic: Problems with control the size of the lat-lon tick labels and the position of my colorbar

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

Current Time: Wed Oct 08 09:18:28 PDT 2025

Total time taken to generate the page: 0.00510 seconds