LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Linear fit through the zero point [0,0]

Solved!
Go to solution

I need to calculate the slope of a set of data and i want the slope to be forced to go through the zero point [0,0].

I tried the Linear fit.vi but i cant find a way to get the slope value through the zero point.

 

For example you can do it in excel by setting the third argument to false or 0 like in the example below.

LINEST(DataAccending!C8:C207;DataAccending!B8:B207;0)

 

How do i solve this in labview?

Thx.

0 Kudos
Message 1 of 6
(344 Views)
Solution
Accepted by tokar

You may use the General Polynomial Fit vi with polynomial order = 1 and constraining the 0 order coefficient to 0 in the Coefficient Constraint input.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 6
(337 Views)

If I had this problem, I'd start with Pen and Paper, write down the equations for least-squares to fit, then program the (very simple) algebraic calculation to get the slope of the best-fit line (the equation, of course, is y = mx).  Bound to beat a "general least-squares" routine, plus the fun of "doing the math".

 

@toker:  Were you able to get an answer by following the previous suggestions?

 

Bob Schor

0 Kudos
Message 3 of 6
(275 Views)

It works!

Thx alot!

 

I also find another solution, see below.

 

tokar_0-1722483771764.png

 

0 Kudos
Message 4 of 6
(267 Views)

You definitely don't need a formula node anywhere!

 

(se also my slide #13 from a few years ago)

0 Kudos
Message 5 of 6
(262 Views)

Here's are two alternatives to do a linear fit with the offset forced to [0,0]

 

altenbach_0-1722486818631.png

 

0 Kudos
Message 6 of 6
(253 Views)