LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Min and Max On An Array

Solved!
Go to solution

Hi. I want to realize a program where I want to generate a sine and take only the positive monotonic part. 

So i tought to find the min and max index of the function and realize a program like the one attached.

As you can see if you set the frequency at 10Hz it works fine... the problem is when you change the frequency for example at 20 or 50H...it seems that it doesn't find the min and max properly. 

Can you suggest me some tips?

Thank you

 

0 Kudos
Message 1 of 6
(3,633 Views)

The problem is with your Express vi set up.  Select "Automatic" for number of samples and Check "Integer number of cycles". 

Capture.PNG


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 6
(3,628 Views)

mmm no it doesn't work 😞

0 Kudos
Message 3 of 6
(3,625 Views)

At higher frequencies, you have multiple peaks and valleys.  Which one is chosen for getting the max index and which one for the min index?  It looks like you are looking for the index values that are greater than the max index AND less than the min index to zero out.  But suppose the Min index winds up coming before the Max index?  That boolean condition will never be true.

 

And do you want to zero out all the decreasing parts of the slopes?  Even if you did not have an index detection problem, it is still only geared towards the first peak/valley combo and is not geared towards to dealing with multiple peaks and valleys.

0 Kudos
Message 4 of 6
(3,606 Views)
Solution
Accepted by topic author s.turino84

@s.turino84 wrote:

and take only the positive monotonic part.


This means the derivative is positive.  So do a derivative.  If the derivative is greater than 0 keep the current value, otherwise set to 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 5 of 6
(3,600 Views)

Hi cross instead yesterday i thought it in the way you will find in the VI attached. I used the shift register to compare the i-value with the i-1-value. If the i-value is > than the i-1 value I set it as output otherwise in the other cases I set it as 0 except when the i-value = max/min value) ....
but to be honest I prefer your solution that is more clear 🙂 so thank you Smiley Tongue

 

 

0 Kudos
Message 6 of 6
(3,572 Views)