02-14-2012 11:25 AM
I was wondering if Labview has the capability to create the coefficients to an equation in the form of Ax3 + Ax2 + Ax + B if just given a dataset like the attached. I'm looking for something like if in Excel where you right click on the graph and add trendline. You can then display the equation.
I've tried the general fit vis in the fitting folder but they don't reproduce the waveform as well as the cubic spline. But then the spline just gives me back the data I input into it which is useless, IMO. If there is no way to get an equation from LV, is there a way to increase the dataset on the output of the cubic spline vi? I feed in 25 data points and I get back out 25 datapoints. Is there a way to get out 200 datapoints? I'm trying to interpolate the values between the datapoints that I feed it. Or is there a better/different way to accomplish what I'm trying to do?
02-14-2012 12:24 PM
First, your data does not look like a very good match to a quadratic curve. A 4th order polynomial fits a little better until you get close to the ends of the data where the fitted curve takes off.
Fits only work as well as the model or equation matches the data.
Did you look at the General Polynomial Fit.vi in the Mathematics >> Fitting palette? It returns the coefficients as well as data fitted to the input X Array. You can then use the Polynomial Evaluation.vi to plot the equation over as many points as you wish.
An XY graph seems like a better choice than the waveform graph because your X values are not uniformly spaced. This also makes it more obvious that your data is not polynomial.
Lynn
02-17-2012 08:41 AM
I'm just amazed with the functionality of LabView. The more you dig, the more stuff you find. It isn't exactly what I wanted, but it is close enough. And if someone is looking at this in the future I would paste the solution I found.
Don't know if anyone wants to answer this, but how do you insert code into a post? I try to copy the code (CTRL-C from LV) and using the "Insert Code" button, but I can't paste the code into the pop-up. CTRL-V doesn't do anything and even when I try to right click, paste is grayed out. But I can paste the code in paint/word, etc.
02-17-2012 02:11 PM
Digging can be fun! The search tool sometimes is helpful also.
Do not use Insert Code from the toolbar. Look below the text box where it says "Attachments". Below that is a button marked "Choose File". Pressing this button will bring up a file dialog which allows you to select the file you wish to attach. If your VI has subVIs which are not from LabVIEW's vi.lib, then zip those together with the main VI before attaching.
Lynn