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 to make a graph y=mx+b ?

hello

 

I need to do a graph XY type y=mx+b

I want to put 2 numerical controls (1 for b and 1 for m) and represent in the graph.

I don´t have ideias how to make it.

 

Can everyone explain to me how to do it. Help me 🙂

 

Thanks

0 Kudos
Message 1 of 5
(4,114 Views)

What have you already tried? Post your code. This is not a terribly complicated problem. Start with a For loop, and a chart with the terminal inside the loop. If you wire the "i" terminal of the For loop to the chart, you'll get y=x. Then it's a simple matter of math to add in the "m" and "b" terms.

0 Kudos
Message 2 of 5
(4,108 Views)

You can use the Ramp function to create an array of X's.  Then do the math on that to get your array of Y's.

0 Kudos
Message 3 of 5
(4,103 Views)

My guess is that you are looking for a "Plot" function like you would find on a TI calculator.

 

You aren't going to find a function like that in most programming languages.  You're going to have to write it yourself!  What those plotting functions are really doing are creating two arrays - one of "X" values, and one of "Y".  You first need to generate an array of X values, and then generate your array of Y values by evaluating your linear equation at each X.

 

Once you have your arrays, in LabVIEW you can just "bundle" them and dump them in to an XY plot.

0 Kudos
Message 4 of 5
(4,083 Views)

This sounds like it may be homework so I'll make you do the work, but I'll help you get pointed in the right direction.

 

I'll bet you do have ideas on how to make it. You already said that you want to make a graph. In fact you said that you want to make an XY graph. What does it require?

 

You have a formula Y=mX+b and you want controls for m and b. These controls will be wired to the math of the formula and the output needs to generate the Y data for the XY graph.

 

There should be a loop or as suggested a ramp to generate various points for the X data. Run the Xs through the formula to generate the Ys. Now combine the resulting data for the graph.

 

To graph a new line, you can either re-run the program or put the whole thing in a loop so that it re-runs automatically.

 

Also, there are some tutorials that can really help out learning LabVIEW if that is what is holding you up.

 

 

Show us some code and we can get more specific.

0 Kudos
Message 5 of 5
(4,012 Views)