From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I plot limit lines with x-domain smaller than the actual data x-domain?

Solved!
Go to solution

Very, very new to LabView programming, so bear with me...

 

My program is taking a data array of frequency points, passing it through a formula node that calculates a value for a limit line based on the frequency, then plotting this limit line array as well as the actual data array gathered by the instrument as functions of the frequency.

 

My problem is that I want the limit line to only be plotted from frequency values of 0.5 to 20, but the frequency array and actual data array contain many points outside this range, both lower than 0.5 and above 20. I still want to plot all of the actual data values...

 

My initial thought was to introduce a conditional statement in the formula node to only use the equation to calculate the limit line values when (X>=0.5 && X<=20). However, what would I use as my "else" case for this conditional? I don't want to simply set them to 0 if they fall outside the range, because I don't want awkward looking lines on the plot jump straight from 0 to the actual value at X=0.5 or in the opposite direction at X=20. 

 

Right now, all of these arrays (frequency, calculated limit line values, actual data) are each an element of the "MainDataArray" (an array of arrays). Will I have to make a new array to contain the subset of frequency values being used by the limit line values in order to get it to plot correctly, or is there some other way that I can simply "cut off" plotting for the limit line values at certain frequency values (x-values)?

0 Kudos
Message 1 of 7
(2,988 Views)

Why can't you disable auto-scaling and just set your x-axis on the graph to start and end at those limits? Am I missing something?

 

If you share your code, it may be easier to help if the above isn't the solution.

 

Edit: Nevermind I see what you're saying. Set the elements of the limit line to NaN if you don't want to display them.

Chart NaN.PNG

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 7
(2,980 Views)
  1. You can use an xy graph instead and have full control of the x-values for each of the plots.
  2. If you use a plain waveform graph, you need to pad the truncated data with NaN values as has been mentioned.
  3. You can wire an array of waveforms, each with it's own x0 and dx.
  4. use an array of clusters with different [x0,xd,array].

 

Here's an example for case #4:

 

 

 

 

Please show us your code with some typical data.

 

 

 

0 Kudos
Message 3 of 7
(2,949 Views)

How would I assign NaN to the array values using the formula node, or is that not possible?

0 Kudos
Message 4 of 7
(2,903 Views)

Why would you need a formula node?

0 Kudos
Message 5 of 7
(2,869 Views)

Right now, the equation in one of my formula nodes is: 

Z=(X>=0.5 && X<5)?1.11111*X-26.5556:
(X>=5 && X<10)?0.4*X-23:
(X>=10 && X<=18)?0.375*X-22.75;

But this is giving a "missing colon" error..... how do I make Z = NaN for values where (X < 0.5 && X > 20)?

0 Kudos
Message 6 of 7
(2,865 Views)
Solution
Accepted by topic author j.warren16

Formula Nodes are slow. See here.

 

If you have to use a formula node, which you don't, you can do NaN as a variable like this:

NaN Formula.png

(You forgot your Else case at the end of the formula, that's why you have an error.)

 

Without the formula node, you could do it like this:

NaN Case Structure.png

You can't do floating point in to a case structure, but if you multiply by a factor of 10 for the precision you need, you can use the integer values for the case structure. Default to NaN, so when it is out of all the other ranges, you get NaN.

 

One of the other cases FYI:

Integer Case.PNG

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 7 of 7
(2,860 Views)