09-24-2014 01:33 PM - edited 09-24-2014 01:35 PM
Here I modified it to do what you want.
09-24-2014 01:44 PM - edited 09-24-2014 01:46 PM
I guess I was late
I also took the NaN route but the case structure seemed silly
I think the OP should explain back to us WHY NaN's don't plot.
Bill, You missed the Plot visability checkbox
09-24-2014 01:53 PM
@JÞB wrote:
Bill, You missed the Plot visibility checkbox
That's a relatively new feature that I don't even remember it exists.
09-24-2014 01:59 PM
Thank you RavensFan and Jeff! I was almost there but I couldn't figure out how to make the signal disappear when the button is unclicked. A google search revealed that NaN means 'not a number' so if the condition is false, I don't want to display 0 becuase that would be a straight line, I want to display NaN which is nothing!
Just out of curiousity, why is it silly to use a case structure and would it be bad practice if I didn't use the select function and kept the = condition that I previously had? It's working now but I kinda kept my old structure.
Why does 'waveform chart' show big waves while 'all 3 signals together' shows the entire signal?
09-24-2014 02:08 PM
Equal to True is just plain silly no matter whether you use the Select function or a case structure. (Check the Rube Goldberg thread.) If you feed in a True and compare to true, what do you get? A true. Feed in a False and =True, you get a False. The =T part is just pointless. Remove the equals and the True constant in your code and you will see the exact same results.
The reason I big Select rather than Case Structure. I use a case structure when there are things that need to or cannot execute depending on the condition. Or if there is more than one output that depends on the condition. When there is a simple Either/Or like we have here, then Select is simple enough to use and you see both possibilities at once without one being hidden.
09-24-2014 02:09 PM
Just out of curiousity, why is it silly to use a case structure and would it be bad practice if I didn't use the select function and kept the = condition that I previously had? It's working now but I kinda kept my old structure.
Why does 'waveform chart' show big waves while 'all 3 signals together' shows the entire signal?
Mostly do to readability. Let LabVIEW work with the arrays directly whenever possible. You'll find things to be a lot easier that way.
The DDT does weird things. That's why we tell you to avoid using it.
Do you also notice that you are throwing away 99 samples from your simulations with each iteration? You get getting 100 samples, but by changing to a scaler, you are throwing a lot of data away.
09-24-2014 02:20 PM
@RavensFan - I read the thread about Rube Goldberg code and I now understand why the equal to true is silly. I also see why we don't need to use a case structure.
@crossrulz - what do you mean I'm throwing away 99 samples and where am I changing the data to scalar? That was mentioned earlier as well but I don't see where that happens and does it affect the data being displayed?
09-24-2014 02:29 PM - edited 09-24-2014 02:33 PM
If a boolean value is equal to TRUE it IS TRUE.
The constant and comparision is Tautologic and hence clutters the code with unneeded operations Just wire the boolean to the case structure selector.
Boolen drive case structures with no sub-vis inside either case are USUALLY replaceable with a "Select" primitive. This is one of those cases. The select primitive permits all the code to be on one sub diagram "Cases hide code" Hidden code is less preferable to a valid alternative. Although it could be said the a select function could always be replaced by a boolean driven case, and therefore needlessly "Bloats" the language it has many advantages. When you really start using the language you'll learn about test case coverage how its metrics are calculated and realize you have better (arguably more acurate) metrics for code coverage using the select function where approprate.
I found the case structure silly because all three non-default cases essentially did the same thing to data of the same type. That screams for an auto-indexed for loop and "Code it once" its much easier to maintain
CAUTION: While the set-up you have know results in arrays of equal size you might lose data if the number of samples from each simulate signal is not the same. You would need some additional code to "Square up the data" before building it into a 2D array (The help file and tutorials will explain why)
EDIT: throwing away 99% Look at the snipett I attached (Drag it to your desktop then drag to to an empty block diagram POOF code!)
The "to dbl" conversion of the DDT only returns the first scalar value without even warning you it did so! (DDTs are evil!) my example shws the correct conversion with the "From DDT express vi"
09-24-2014 02:29 PM
rhupd wrote:
@crossrulz - what do you mean I'm throwing away 99 samples and where am I changing the data to scalar? That was mentioned earlier as well but I don't see where that happens and does it affect the data being displayed?
You simulation Express VI is setup to output 100 samples. Then you use the From Dynamic Data to change the value into a scaler. That conversion right there is where you are throwing away 99 samples.
09-24-2014 02:31 PM
@JÞB wrote:
Bill, You missed the Plot visability checkbox
Also, what would happen if you would replace the array of 3 NaNs with a scalar NaN? 😄
(A scalar NaN would make the code much more maintainable. Currently, if he would add another signal, a seemingly unrelated change would need to be done in the lower left corner...)