From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-26-2020 09:30 AM
Hi,
I am trying to get the polynomial fit a particular data set. The nature of fitted plot is correct but its Y axis is behaving strangely. I ham selecting some region of the parent plot and then trying to fit it using polynomial fit VI. Every time, the fit is giving some strange Y axis data.
I order to cross check its behavior, I fitted the same data set using origin, with same polynomial order (2), but in origin, no such behavior is observed. In origin, the fitted curve is always lying with the data points (which is expected).
Also, in order to verify again, I used some data generated by a quadratic equation and got a proper fitting in LabVIEW as well as in origin.
Now my problem is why LabVIEW polynomial VI is misbehaving for my data points (origin it is coming proper, but I need to use LabVIEW for some real-time calculations)?
The concerned VI with both the data points are attached.
Thank you.
Solved! Go to Solution.
02-26-2020 12:14 PM
There's are quite a few problems with that code, so it's no wonder you get strange results.
It seems you want to be able to fit the data based on the positions of the cursors on a graph and update everytime the cursor moves. But, you're code suggests you are new to LabVIEW. There's no issue with fitting, just your poor implementation. (If you want to compare to your Origin fit then just do a basic fit over the same range. I'll guarantee they match. Use this as a reference - https://www.ni.com/en-ca/innovations/white-papers/08/overview-of-curve-fitting-models-and-methods-in...)
So you need to learn some LabVIEW programing basics - http://www.ni.com/getting-started/labview-basics/. Next you should learn how to use event driven state machines design pattern, then when the cursor values change, you update the fit and re-plot the fit data. This will avoid the rather convoluted loops you have there. This might take some time but well worth the effort.
Craig
02-26-2020 10:13 PM
But using the same VI, when I am fitting the quadratic equation data, the fitting is proper. Then why for the other data set, it is giving different Y values?
02-26-2020 11:36 PM
As suggested, I tried to use polynomial fit VI simply (no complications in the code). I am again having the same problem. VI and a data set is attached.
02-27-2020 04:15 AM - edited 02-27-2020 04:17 AM
Using the supplied code and data I was successful with the following algorithms:
SVD gave the right shape, but the wrong values (this is the default by the way) and LU Decomp, Cholesky and SVD for Rank Deficient H all gave fairly straight lines.
So I'd suggest you look at the algorithms in more depth, and/or just choose a different value (e.g. Givens).
Tweaking the "method" also adjusted the fit - you might prefer one over another.
02-27-2020 05:41 AM
Actually, I am not really able to understand your suggestion. I dont have much idea about these technical term. Im sorry for that.
Can you please help me getting a correct set of Y axis values? The shape of the plot is correct (I cross-checked with that obtained by origin). I think I am missing some very basic point.
Thank you.
02-27-2020 08:21 AM
On your fitting VI, hover near the bottom and find the "algorithm" input.
Right click on it and choose "Create Constant" or "Create > Constant" depending on LabVIEW version. You could also create a control if you prefer.
Change the value (via dropdown box in the created constant/control) to one of the ones I listed and rerun the VI.
02-27-2020 11:43 AM
(Posting by phone, but this thread should be appended to (i.e. merged with) your other thread. No need for diverging discussions of the same vi.)
02-27-2020 12:20 PM - edited 02-27-2020 12:27 PM
Yes, you need to learn some more of the basics of LabVIEW - controls, constants, indicators. In the block diagram press CTRL+H (display help window) then hover over the poly fitting VI. Notice the inputs to the VI? You need to select method and algorithm as cbutcher mentioned. (Origin probably does this for you or only implements one method.)
Here's a simple example where I've added cbutcher's suggestions and made the polynomial fitting options into controls that you can easily change on the front panel. I did provide a method to select a section of the data of interest, but it's not doing anything with cursors... you got lots of help on that here - https://forums.ni.com/t5/LabVIEW/How-to-fix-cursor-at-one-particular-value-X/td-p/4017281
Craig
02-27-2020 09:50 PM - edited 02-27-2020 09:51 PM
Thank you so much for guiding me regarding some very basics of polynomial fit VI. I was really unable to understand what was going on. The confusing thing was that same VI was giving proper Y axis values for a data set generated by using a quadratic equation, but for my other data point, I was getting different Y values.
Thank you again.