11-21-2022 03:20 AM
I have a plot curve.vi (image 1) and I want to extend the plot, similar to the red extensions in image 2.
Giving -x and +x as control inputs to limit the extension of the polynomial fitting array.
What is the best and fastest way to do it?
Solved! Go to Solution.
11-21-2022 03:38 AM - edited 11-21-2022 03:43 AM
Hi Mal,
do your polynomial fitting of your data to get the polynomial coefficients.
Then use those coefficients to calculate a new plot with extended x range!
What have you tried and where are you stuck?
(Do you use the Base or Professional version?)
I just created this in 3mins:
Hint: Learn to stay away from ExpressVIs!
11-21-2022 09:00 AM
It's interesting, thanks!
11-21-2022 09:31 AM
Often, extrapolating a regressed polynomial is a bad idea.
11-21-2022 11:15 AM - edited 11-21-2022 11:29 AM
I agree with Paul that blindly extrapolating is a bad idea. Especially with a 6th order polynomial!
How much do you know about the data? Is there a model (e.g. Truncated Gaussian or Lorentzian, Asymptotically linear on both sides, etc.?). To correctly extrapolate, you need a model that describes the entire f(x) from -inf to inf (or within the desired extrapolation limits), then do a nonlinear fit to the model and extrapolate using the best fit parameters and the model.
From the strange dropoff in the wings of the 6th order polynomial, we can tell that it is not a good model!
On a side note, you definitely don't need any dynamic data and express VIs. Here's the equivalent of your current VI. Arguably simpler!:
11-21-2022 12:25 PM
Hi Altenbach, Paul,
Thanks I agree. How can I manage complex numbers solution? I think you mean probably I can change the x scale for example, how?
11-21-2022 12:40 PM
@Mal123 wrote:
How can I manage complex numbers solution? I think you mean probably I can change the x scale for example, how?
What is there to "manage"? I am not even sure what that means. 😄
Here's a fit to a primitive Lorentzian shape (Definitely not the correct model, so this is just for illustration!). While the fit is not as good as the 6th order polynomial, it only uses 2 instead of 7 parameters. 😄
After fitting we take the best fit parameters (3.97, -0.18 in this case) and evaluate it for an arbitrary range of X values. (Yes, I would use more reasonable guesses as (1, 1), but it still finds it.
Once we know what the data represents and what the theory is, we can come up with a better model. Where does the data come from and what does it mean? What are the units?
11-21-2022 01:05 PM
Hi,
@paul_cardinale wrote:
Often, extrapolating a regressed polynomial is a bad idea.
I strongly agree to this comment!
I just took a 6th order polynomial because it looked better than 2nd to 5th order (and for simplicity of example…) 🙂
11-21-2022 01:07 PM - edited 11-21-2022 01:10 PM
If we allow an x shift (i.e. 3 parameters), the fits already gets better:
Still, not perfect, of course because we need a better model!