11-28-2011 09:34 AM
Looks like your function is linear, so you might try General Linear Fit.vi.
-Jim
11-30-2011 04:28 AM
Pleas mind that i have 2 variables, X and T --> y=f(X,T). So linear fit can not be used as far as i can see, perhaps am i interpreting something wrongly?
regards
11-30-2011 07:50 AM
There are two "linear fit" VIs on the palette. First is Linear Fit.vi that fits a line y=mx+b. The second is General Linear Fit.vi, that fits y=a0*f0(x) + a1*f1(x) + a2*f2(x) + ...
So y is a linear combination of f0, f1, f2, etc.
For your model f0=T*x, f1=x, f2=T, f3=1, y=RH
The inputs to the VI are y, and H, where H is a matrix whose rows correspond to f0, f1, f2,... and the columns correspond to the individual values of each function. So the first element of the first row should be T(0)*x(0), second element T(1)*x(1), ...
The online help for this function shows an example at the bottom that illustrates this.
-Jim
11-30-2011 08:07 AM
Note that linear fits rely on data with a gaussian error distribution. If you have frequent outliers, for some reason or another, you may want to use a fit which uses an error distribution with larger tails (e.g. Lorentzian distribution, corresponding to error using log of absolute value or error - Gaussian distribution corresponds to square of error). Unfortunately, these are usually iterative in nature. I have had good success creating my own error term (sum of log of absolute values of errors) and minimizing it with the downhill simplex minimizer. I generate starting values either using the linear fit or with some other quick data model.
Details on the math behind this type of fitting procedure can be found on the Numerical Recipes website. Look at Chapter 15, and previous chapters for reference.
12-05-2011 07:40 AM
I am quite not sure as how to implement your solution in Labview... i know more or less how to use MATLAB for this, however, when looking through labview, i need to use the downhill simplex algorithm, which requires a function definition in text mode... i do not know how to define my error in the way labview asks since i have just a set of obervations y= f(T,RH) and not a function that calculates the error... I do not know how to create one in just a single text line as Labview is requiring... could you be a bit more explicit on this?
regards
12-05-2011 09:33 AM
It works!
I figured out how to do it... basically i have to build a loop to construct a error equation with all my observation points and estimated values..., this creates a huge string but... it works!!
Thanks!