LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plot a curve on an xy graph with an equation

Solved!
Go to solution

I need to plot several curves on an xy graph.

I know how to plot multiple curves I just don't know how to do it with an equation.

 

example    y=2.039+1.116*exp(.01468*x)

 

I did this with point to point manually, but will have many of these with plus and minus also.

So plotting with an equation would save alot of time.

 

xy grpah example.PNGxy graph line.PNG

0 Kudos
Message 1 of 8
(9,957 Views)
Solution
Accepted by topic author RedneckNerd

Hey,

I'm not sure if I get your problem correctly, but you can do all kind of maths with arrays as well (even for example multiple an array with a single number or another array) and you can bundle them to be plotted on xy graphs.

For example in this snippet (you can copy this image to the block diagram and use the code from it) I use the for loop to give an array to be the x axis (you can use your existing x axis data in an array) and then I do several mathematics on it: first I do your formula to calculate y data, secondly I do a truncated version of your formula to get another set of y data and lastly I use a mathscript node to get the same data as the first one (although with slower performance, especially if you use many formulas as primitives give much better performance than mathscript). Then I bundle them into clusters and build an array of them to plot all of them

formula.png

 

Then the result is this with plot 0 hiding plot 2 as both have the same data.

graph.bmp

 

I hope you were looking for some help like this.

__________________
Engage! using LV2015
Message 2 of 8
(9,944 Views)

Create an x-ramp and then apply the formula to calculate the y-values. Bundle the two for a plot. If all plots share the same x-values, you only need to create the ramp once.

0 Kudos
Message 3 of 8
(9,942 Views)

jeanlucpicard This worked perfectly thanks.

The bundling of the data and using the for loop is exactly what I was looking for.

0 Kudos
Message 4 of 8
(9,896 Views)

I'm glad I could help. However, if you need an x-axis with a sub-1 resolution (i.e. with decimal values) you might want to use the ramp as altenbach suggested instead of the for loop

__________________
Engage! using LV2015
0 Kudos
Message 5 of 8
(9,887 Views)

Currently i don't need sub one yet, but it will come.

 

Is the x-ramp just math inside of the for loop or is it a function?

0 Kudos
Message 6 of 8
(9,879 Views)

There is "ramp pattern" in the signal processing...signal generation palette. Just give it start, end, and number of points.

Message 7 of 8
(9,876 Views)

Thanks.  This also helped me to find another vi I have been looking for!

0 Kudos
Message 8 of 8
(9,873 Views)