LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How make for loop with min max value ina Array

Xd now you tell me is min max function, thanxxxx
0 Kudos
Message 41 of 55
(2,339 Views)

@crisdragon wrote:
Xd now you tell me is min max function, thanxxxx

Well, I assume that one is allowed, just not "Array Min&Max". Who knows?  😄

 

Make sure to show us the final code so we can comment.

0 Kudos
Message 42 of 55
(2,332 Views)

@altenbach wrote:

@crisdragon wrote:
Xd now you tell me is min max function, thanxxxx

Well, I assume that one is allowed, just not "Array Min&Max". Who knows?  😄

 

Make sure to show us the final code so we can comment.


I had assumed that one was NOT allowed.  That the problem was taking Array Min & Max and duplicating with the most basic of LabVIEW functions.  Min/Max is great in that it actually eliminates a comparison and a select function.  Or comparison and a case structure.

0 Kudos
Message 43 of 55
(2,313 Views)

Almost done, i think is last problem, why i cant ad wire from max in place after index array - the wire connects more than one data source 😕

0 Kudos
Message 44 of 55
(2,307 Views)

Your code is not comparing the CURRENT Max or the CURRENT Min.  Your C based code isn't even accurate.  Think of shift registers as Integers initialized in separate functions.  In C based code, in order to keep track of who the Max and Min are, you would set up Ints Max and Min, yes?  Then, when a value has been determined to be less than or greater than either, the corresponding values are updated.  Think of a shift register like that.  That's why everyone has been saying 2 shift registers.  Your indicators are not the same as integers.  They are value displays.  They do nothing else but display whatever the current value is, and your code is updating them incorrectly.  Someone mentioned using Local Variables... but no.  Data flow goes from left to right.  Once you've gone as far right as you can go, what has to happen?  You have to start from the left again.  Which is why loops are circles.  Then you start over left to right.  Where does the Max value come from?  Who is the max value being compared to?  Same with the Min?  Ask these questions when programming.

 

0 Kudos
Message 45 of 55
(2,271 Views)

Ok its done, but i think this looks not good. Anyone can rate this?

0 Kudos
Message 46 of 55
(2,268 Views)

What's the task again?  To simply find the single max and min elements of an array or to put them in order?

0 Kudos
Message 47 of 55
(2,264 Views)

@crisdragon wrote:

Ok its done, but i think this looks not good. Anyone can rate this?


You are ignoring the first element. Min and Max should be scalars, not arrays. indicators belong after the loop. No need to update them every nanosecond with uninteresting intermediary values.

 

Here is some simple code to get the max, see if you can expand it for the full problem 😉

 

 

Message 48 of 55
(2,251 Views)

Your code is awesome but i dont understand -infinity. 

0 Kudos
Message 49 of 55
(2,248 Views)

@crisdragon wrote:

Simply find max and min without using MIN & MAX Array. But this work good, what i should change?


Define "works"! Define "this"! (it has been a long thread!)

 

  • Does it work for any size input array? (e.g. 1000000 elements)
  • Does it work if all input values are negative?
  • Does it work if the input array is empty?
  • Does it work if the input contains elements that are NaN?

If you want us to verify the code, attach the actual VI!

0 Kudos
Message 50 of 55
(2,236 Views)