04-14-2014 05:50 PM
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.
Thank You
Regards
AG
Solved! Go to Solution.
04-14-2014 05:54 PM
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)
04-14-2014 06:01 PM
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,
04-14-2014 08:10 PM
04-14-2014 08:20 PM
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.
04-15-2014 01:06 PM
Thank you so much 0utlaw and RavensFan.
Regards
AG