LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Discarding values higher than ranges

Solved!
Go to solution

Hi everyone! 

                       I need some help. What I am trying to do is to take an array of 51 elements and plotting its PSD and applying statistics further.

But before that I want to scan that either the array elements are within my define ranges. So, if the amplitudes of these all 51 values are less than 8 and greater than -8 then pass it to power spectrum. But if this is not the case then go back and take new 51 elements array. 

Now question is how to discard this array (which elements are not in range) and replace it with new one (coming from stimulate signal). Because I don't want to see NaN in ArrayM but values continously coming within my defined ranges.

I hope that I delivered my point clearly. 

 

Here's my messy code sorry for that. Smiley Happy

 

Thank You

 

Regards 

 

AG

0 Kudos
Message 1 of 6
(2,529 Views)

Put the Simulate Signal in its own while loop so that it can repeate.  Stop that while loop whenever the values are In Range.

 

Use the In Range and Coerce function to determine if it is in range instead of 3 separate functions (<, >, OR)

0 Kudos
Message 2 of 6
(2,520 Views)
Solution
Accepted by topic author AmnaG

Hello AmnaG,

 

The simplest way to achieve this with your current code is to place your analysis within the true case of your case structure - this will only process the data and update your UI if the "acquisition" is in range. Be aware that this won't scale well- I'd recommend a state machine architecture that repeats an acquisition until your conditions are met and then proceeds to processing the data.

 

Also, you may want to consider using the In Range and Coerce function rather than max/min etc.  Using the "In Range?" output makes it clear to any future developer exactly what you're attempting to do.

 

Nice job on the in-VI documentation, by the way, and thank you for ensuring the VI is in a usable state without modification before posting!  It's incredibly helpful.

 

Best Regards,

Tom L.
0 Kudos
Message 3 of 6
(2,513 Views)
@RavensFan Here I am using stimulate signal to just test my program but in actual the signal will be coming from acquisition (Biosemi: I am working inside the while loop of Activeview code) so I think I would most possibly try to eliminate use of any other while loops. @0utlaw I am trying to take another (new) value from stimulate signal when condition is true and repeat the same (means check the range). So my priority is keeping processing of data beside. If there is any simple way? By the way thanks for replies. Regards AG
0 Kudos
Message 4 of 6
(2,469 Views)

When you need to repeat something, then you need a loop.

 

You can either repeat the acquisition until it meets the condition.  Or you can have like Outlaw suggests where you only have the one main loop, but you only do the other stuff when the conditions are met by putting it inside a case structure.

 

You can do either method.  I would suggest using Outlaw's architecture. It is 1 loop with one major case structure inside.

Message 5 of 6
(2,463 Views)

Thank you so much 0utlaw and RavensFan.

 

Regards

 

AG

0 Kudos
Message 6 of 6
(2,410 Views)