Return the bigger values of 2 arrays

Friday, December 10th, 2010

I came up with a similar question (<Return #elements of an array greater than a certain value>) before, and today this one “What’s the efficient way of comparing 2 arrays and returning an array with the bigger values?” was posted in gsdzone.net forum.

This is not a complex problem and many responses were given. But all of them suggested using a for loop to compare the elements one by one. Most of the comparison and numeric nodes in LabVIEW are polymorphic and we should take use of them efficiently. I tried the following code and it works 🙂

So a single Max & Min node can do the job.

A thought that may or may not be helpful (or even correct!) in optimization: Always try to do it with polymorphic nodes when you did it with a loop; always try to do it in one loop when you did it with several loops.
Thanks to rogel who brought up this problem.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: