LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Linear Fit VI with only "y" data

Solved!
Go to solution

Hello,

 

I would like to find the slope of a data set. But the problem is the x values are not time or any other indicator that can be saved but only the number of how many data I have. Thus I only have the y data in my hand to work with. I have tried using the Linear Fit VI but can't seem to understand the error I am getting. (For the x data I could use the "Array Size VI" and just find how big is my array is and use it, but I think another cleaner solution should be available.)

 

I am attaching the data set and the VI below.

 

Thanks,

Diural

Download All
0 Kudos
Message 1 of 10
(224 Views)
Solution
Accepted by Diural

(Sorry, I cannot open Vis saved in LabVIEW 2021. Consider "save for previous" before attaching. I would also give it a reasonable name. "Untitled 1.vi" is NOT reasonable!)

 

You can use the array index as x-values.

 

 

altenbach_0-1655974254073.png

 

(Of course slope and intercept depends on the definition of the x-values, so take that into account)

0 Kudos
Message 2 of 10
(215 Views)

Also consider voting for this idea. 😄

Message 3 of 10
(208 Views)

As always thanks altenbach, and yes def. voted 😄

 

Take care,

Diural

0 Kudos
Message 4 of 10
(189 Views)

Hey altenbach,

 

I have tried it again when I had time and its still is not workinh for some reason. I have saved as previous LV2012 and attached the required txt file. 

I have even created 2 array with only 4 input to test it out but can't seem the figure the "problably trivial" problem. I appreciate all your help.

 

Error: "These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Context Help window to see what data type is required.
The type of the source is 1D array of
double [64-bit real (~15 digit precision)].
The type of the sink is double [64-bit real (~15 digit precision)]."

 

Cheers,

Diural

Download All
0 Kudos
Message 5 of 10
(142 Views)

Hi Diural,

 


@Diural wrote:

I have saved as previous LV2012


No, you attached a LV2020 VI…

Best regards,
GerdW


using LV2016/2019/2020 on Win8.1/10+cRIO
0 Kudos
Message 6 of 10
(138 Views)

Hey,

 

Thanks for pointing out, I think I did something wrong while saving, here you go 🙁

Download All
0 Kudos
Message 7 of 10
(133 Views)

LabVIEW 2020 is fine. I am currently on the road, will look at it later.

0 Kudos
Message 8 of 10
(125 Views)
Solution
Accepted by Diural

Hi Diural,

 


@Diural wrote:

I think I did something wrong 🙁


Yes.

Why do you (try to) use the PtByPt version of the LinearFit?

Why don't you use the regular LinearFit function found in the Math->Fitting palette?

 

Btw. why don't you use AutoCleanup?

Best regards,
GerdW


using LV2016/2019/2020 on Win8.1/10+cRIO
Message 9 of 10
(118 Views)

Hello GerdW,

 

I normally use autoclean but I must have forget while trying to chnage stuff before posting it here. Also you were right the regular fit was what i was looking for, my vi is now working. Once agaian thanks a bunch and take care.

 

Cheer,

Diural

0 Kudos
Message 10 of 10
(103 Views)