LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

regression, y=ax+bx2

Solved!
Go to solution

From measurements I’m having 4 sets of pressure and corresponding flow.

Plotted in a XY-plot, the curve follows the form

 

y=ax2+bx, where y is the pressure and x is the flow.

 

I need to get the values of a and b, and R2.

The curve have to cross in x, y= 0,0.

 

From the math palette I can see that Labview offers a bunch of different regression possibilities, but which to use and how?

Can anybody help me?

 

Regards Michael

0 Kudos
Message 1 of 15
(5,652 Views)
Solution
Accepted by topic author Michael.Koppelgaard

Hi Michael,

 

GeneralPolynomialFit would be an option to use…

 

Don't forget to include your (0, 0) point. You may even play around with different weights for your measurement values…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(5,648 Views)

Yes you are right.

Am I right, when I say that there a no exact way to ensure that the curve cross in x,y =0,0 ?

When using the weight, I thought that if I give the values 1,1,1,1, 1000 it would ensure x,y through 0,0.

But I found that too high a weight for 0,0 gives values far from 0,0.

The weight have to be high but not to high

 

But do I have to play for every new set of data, then it’s no good.

What do you think?

 

R2 is that the residual value or the error?

0 Kudos
Message 3 of 15
(5,630 Views)

Hi Michael,

 

When using the weight, I thought that if I give the values 1,1,1,1, 1000 it would ensure x,y through 0,0.

When reading the help for the function (as you should always do as a beginner) you would have noticed the acceptable range for weight values…

 

R2 is that the residual value or the error?

You should know on your own what you need to calculate. Don't you?

Usually there is a residual value R - or it's squared value R²…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 15
(5,623 Views)

I read about the weights and only found this:

 

"Weight is the array of weights for the observations (X, Y). Weight must be the same size as Y. If you do not wire an input to Weight, the VI sets all elements of Weight to 1. If an element of Weight is less than 0, the VI uses the absolute value of the element. "

 

 

Not anything about at max value

 

0 Kudos
Message 5 of 15
(5,615 Views)

Hi Michael,

 

it explicitely mentions "1" and "0" and the help also shows some formulas, when you scroll down to the bottom.

 

So the accepted range is (0, 1)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 15
(5,613 Views)
Solution
Accepted by topic author Michael.Koppelgaard

Now I read the documentations for the function (as you advised me) one time more and found a very useful control.

With the “Coefficient Constraint” you are able to control that the curve crosses in 0,0.

 

As I mentioned the function have the form

y=ax^2+bx+c,

but since the curve should cross in (0,0) , c have to be 0. Therefore the constrain for coefficient 0 should be 0.

 

And it worksSmiley Very Happy

 

Thanks for your help.

0 Kudos
Message 7 of 15
(5,597 Views)

Michael.Koppelgaard wrote:

As I mentioned the function have the form

y=ax^2+bx+c,

but since the curve should cross in (0,0) , c have to be 0. Therefore the constrain for coefficient 0 should be 0.


Better would be to setup the simpler system with only the a and b terms, then use General linear fit to solve it.

0 Kudos
Message 8 of 15
(5,578 Views)

@altenbach wrote:
Better would be to setup the simpler system with only the a and b terms, then use General linear fit to solve it.

Here's what I had in mind.

 

 

Download All
0 Kudos
Message 9 of 15
(5,571 Views)

Ahh - you can also use linear fit. Funny… the name suggests that it have to be a linear function.

I will most certainly try it out later this weekend.

Thank you for your advice.

0 Kudos
Message 10 of 15
(5,552 Views)