LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help on how to not have intercept pass through 0 using General Linear Fit

Solved!
Go to solution

I have data the consists of a single column of y values and multiple columns of x values.  What I am trying to do is re-create an excel spreadsheet calculation in Labview.  The excel sheet using the Linest function, however the intercept is calculated normally (const = true).  I have read through the forum and found that I can use the General Linear Fit vi to perform my calculation, but the this vi forces the intercept to be zero.  This there a way in labview to do the fitting like it is done in excel?

0 Kudos
Message 1 of 11
(3,049 Views)

Just use the plain linear fit!

 

(If you are discussing something you found in the forum, you should always include a link so we can see what you area talking about. What you probably found was a workaround that forces an intercept of zero for a special scenario. If you want to use general linear fit anyway, your matrix simply also needs a constant term)

 

If you still have problems, show us your code and some data.

0 Kudos
Message 2 of 11
(3,045 Views)

Sorry here is the previous post that I found:

There-is-a-function-in-excel-called-linest-that-will-perform

 

What you have suggested using the linear fit does not allow me to use an array for the x values.

0 Kudos
Message 3 of 11
(3,035 Views)

That should have said "does not allow a matrix for the x values"

0 Kudos
Message 4 of 11
(3,030 Views)

@Terry_S wrote:

That should have said "does not allow a matrix for the x values"


I don't understand what you mean by that. The x-values are always an array. if you only had a single x value, linear fit would make no sense.

 

Please attach your code with some typical data.

0 Kudos
Message 5 of 11
(3,015 Views)

In the array pallet, there are the Array to Matrix and Matrix to Array functions. Even though you may have a matrix with N rows and 1 column, it will create a 2d array. Just index the first column of the array, which will return the 1d array that you need. The snippet I have attached illustrates this.

 

 Matrix to Array to Matrix.png

 

In the Functions>>Mathematics>>Fitting>>Advanced Curve Fitting pallet, there are many more functions that might be of use to you.

0 Kudos
Message 6 of 11
(3,011 Views)

Please don't bring matrix datatypes into the discussions.

 

We are talking about 2D arrays here. none of the fitting VIs deal with matrix datatypes.

0 Kudos
Message 7 of 11
(2,997 Views)

I think I have given everyone the wrong idea with my poor wording.  What I what to do in a muliple linear regression.  The image below shows an example of what I have so far.

Multiple Linear Regression.jpg

 

I need to have the same Coefficent values that I get when using the Linest funtion in Excel.  The Linest function can be set to calculate b normally or set to zero.  I my case I have is set to calculate normally.  How can I do this in Labview?

 

 

0 Kudos
Message 8 of 11
(2,995 Views)
Solution
Accepted by topic author Terry_S

Try appending an additional column to the data array that is all 1's.

Message 9 of 11
(2,988 Views)
Solution
Accepted by topic author Terry_S
Message 10 of 11
(2,970 Views)