Yesterday was a warmup for today's VI, the "General LS Linear Fit.vi". The idea is the same (Least Squares Fitting) so many of the choices are the same. What this version gives you is control over the basis functions for the fit. It is worth pointing out that the term "linear" refers to the parameters of the fit, not the basis functions. Many times when you see functions like sin(x) and exp(x^2) you automatically think that you are in for a non-linear fit. If you are simply fitting to a linear combination of those non-linear functions (ie. a sin(x) + b exp(x^2)), then you can use this method instead. Advantages to using a linear LS when possible are speed and convergence. No derivatives or initial guesses to fuss with either.
For today's example I am back to generating fake data the usual way, but I am demonstrating another feature of general LS fitting, the ability to perform multidimensional fits. To use this VI you are responsible for calculating the design matrix H, with a column for each basis function which is evaluated at each data point. These data points aren't necessarily just x, they can be (x,y) or (x,y,z) as long as you are consistent with how you order them. In the example, I do a 2D fit to the function a*exp(-x^2-y^2) + b cos (x^2 + y^2).
VIOTD groundrules here.