06-23-2022 03:26 AM
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
Solved! Go to Solution.
06-23-2022 03:47 AM - edited 06-23-2022 03:54 AM
(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.
(Of course slope and intercept depends on the definition of the x-values, so take that into account)
06-23-2022 03:58 AM
Also consider voting for this idea. 😄
06-23-2022 04:57 AM
As always thanks altenbach, and yes def. voted 😄
Take care,
Diural
06-24-2022 02:54 AM
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
06-24-2022 03:13 AM
06-24-2022 03:23 AM
Hey,
Thanks for pointing out, I think I did something wrong while saving, here you go 🙁
06-24-2022 04:00 AM
LabVIEW 2020 is fine. I am currently on the road, will look at it later.
06-24-2022 04:36 AM
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?
06-24-2022 07:41 AM
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