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.
Solved! Go to Solution.
(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)
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)]."
I think I did something wrong 🙁
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?
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.