Return #elements of an array greater than a certain value

Monday, September 20th, 2010

Some one asked the titled question in a forum (link), and many answers were given. This qustion is not hard and may not bother you at all. But the conclusion that a loop was neccesary is incorrect.

Above is an answer given by bincker, sorry for the watermark. The idea was to initialize a number and use the shift register as a counter. Add by one when the condition is fulfilled. Three conditions are listed in this case.

Or, we can do it this way (by me):

I don’t know what happened in the “greater than” node, but the conclusion is we do not really need a loop to do that. There might be a traversal as well but the whole calculate is much simpler. And the bottom line is, thanks to the polymorphism of LabVIEW node, we can connect array and a single data to some nodes and do the calculations in one iteration.

Thanks for sx056 who brought up this question and bincker who gave me a hint.

Advertisements

2 comments on “Return #elements of an array greater than a certain value

  1. […] December 10, 2010 tags: LabVIEW, Math by foolooo 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 […]

  2. […] 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 […]

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: