From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding the minimum number greater than zero in an array

0 Kudos
Message 21 of 27
(1,327 Views)

I have created the following sub-VI to find the Max and Non-zero Minimum of an array (assuming positive values) using a basic algorithm because I don't like loops. You can replicate in excell to understand the maths, the only difference is the [Round Down to Nearest Integer] function is the INT() function in excel.

 

Regards

 

R Gibbs

 

ArrayMaxMin Diagram.png

 

 

 

 

0 Kudos
Message 22 of 27
(1,222 Views)
That's not a subvi, just an image.
0 Kudos
Message 23 of 27
(1,199 Views)

@rg8766 wrote:

ArrayMaxMin Diagram.png


One immediately obvious serious flaw is the fact that the "Non-Zero Min" is most likely not binary indentical to the array element at that location. After all, you are doing some serious manipulation on it. A much better solution would be to index out the element from the original array, once you have the "Min index".

 

I have not verified the correct operation of your code, just looking at the picture for now. I will, after you attach the actual VI.

0 Kudos
Message 24 of 27
(1,182 Views)

I was just trying to help with the solution I came up with when I wanted the same functionality. This is my first time on the forum. I wont bother in future if Mr 31.5K "Knight of NI" is going to be so abrupt. I have attached the actual .vi file (wasn't aware that a "listing" of the code ie. a picture wasn't sufficient). It works fine for me, and I have no idea what "binary indentical" means. I am only 3 months into LabView and have been impressed by the tutorials NI produce, so I will not let Mr Altenbach tarnish that for me.

0 Kudos
Message 25 of 27
(1,153 Views)

So you will wait until you have a problem with the code and wonder why it doesn't work the way you expect?

 

Not all numbers can be represented exactly in a binary number system.  Did you know that 1 divided by 3 then multiplied by 3 in math equals 1, but in a computer doesn't?  That is what he is talking about.  (There are probably better examples than this.)

 

If you are aware of the pitfalls of certain operations, you can prevent that from affecting how your code performs.

 

 

0 Kudos
Message 26 of 27
(1,143 Views)

@RavensFan wrote:

Not all numbers can be represented exactly in a binary number system.  Did you know that 1 divided by 3 then multiplied by 3 in math equals 1, but in a computer doesn't?  That is what he is talking about.  (There are probably better examples than this.)


Here is another example: Floating Zero

It uses a subtraction by 0.1 and stopping a loop when it equals 0.  But 0.8 - 0.1 eight times does not equal 0.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 27 of 27
(1,125 Views)