LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Forcing zero intercept

Hello All,
I would like to fit a curve for some data but I want the intercept to go thought zero and there does not seem to be an option to make force a zero intercept. How does one do this? On the same question, how does one calculate the R^2 for a linear curve fit in LabView?
The type of curve I am trying to fit to the data is of the form
y=mx
(the b in y=mx + b is should be zero)

Thank you,
GP
0 Kudos
Message 1 of 7
(3,672 Views)
GP,

I hope you're using LabVIEW 7.1, because I built my example in that version. If not, I can attach a screen shot of the diagram.

The answer is for you to use the General LS Linear Fit VI. Maybe there's an even simpler, more elegant answer for the y=mx case, but this analysis VI was created for your general type of problem. You use it by telling it what functional form you believe the data should follow--in your case, y=mx.

See my attachment and let me know if you have any questions.

Take care,
John
Message 2 of 7
(3,653 Views)
Here's the attachment.
0 Kudos
Message 3 of 7
(3,651 Views)
Hello John,
I did as you outlined in your vi, but the results do not seem to make any sense. I have attached the Vi and the screen shot.
The curve-fitting routine just seems to be way off the mark.
GP
0 Kudos
Message 4 of 7
(3,615 Views)
Here is the screen-shot.
0 Kudos
Message 5 of 7
(3,615 Views)
Sorry John, Just realised that the data points were to blame not the algorithm itself. Let me recheck with some other data points.
Thanks
0 Kudos
Message 6 of 7
(3,604 Views)
There is nothing wrong with John's VI. It is a great idea to use the gen LS fit for this.

The VI seems to work just fine here using synthetic data. You should wire the error out of the GenLSFit to a terminal, maybe your data is pathological in some way?

Please enter you data into the table, then "right-click...data operations...make current values default" before saving. Then attach it again so we can play with your actual values.

Attached is a slightly streamline version of your VI including some data. (My religion prohibits me from using the formula node so I eliminated it. There are easier ways to generate the H matrix in this case.;) )
0 Kudos
Message 7 of 7
(3,598 Views)