11-23-2017 11:01 AM
Hi All,
I have some experimental data that I am trying to fit a particular function that I derived to solve my problem. The form of this equation look something like R=SQRT(A^2+B^2/C^2+D^2)..only far more complex. The values of A B C D varies as a function of the physical property I want to measure, while R is what I measure experimentally. The idea behind this is that I know all but 1 of the parameters on the right hand side terms and I would like to have an initial guess for the parameter unknown to obtain the value of R that is closest to the experimental value. I am attaching a picture of how the model for the exact value of this parameter and the experimental data look like.
I would like to use a fitting function (I am thinking to a non linear least square on the top of my head) to run this iteration process and obtain a good approximation of the unknown value.
Is it possible to do this in LabView?
Kindest Regards,
Michele
11-23-2017 11:20 AM
Yes, it is possible to do non-linear least-squares fitting using LabVIEW. It is also possible to do this in Matlab, C++, Fortran, Pascal, Python, and a whole host of other languages.
If this is your first LabVIEW program, you may want to consider starting with a Programming Language with which you are more familiar. Otherwise, go take a crack at it (I assume, if you have LabVIEW experience, you know how to use LabVIEW Help to find functions, and also know how to use the Web to help you find things) and post your code, meaning "attach your VI (or VIs)". Doing so shows us what you are doing, shows us the version of LabVIEW you are using, gives us an idea of your level of LabVIEW experience, lets us execute/test your code, etc.
Bob Schor
11-23-2017 11:30 AM
Hi Bob,
thanks for your reply, yes I am familiar with LV and I know I can do this with Matlab. I have used fitting functions before, but this problem consists in starting from an initial guess to find the value of my unknown parameter that minimise the error between the experimental data and the model and this problem is new to me.
Although I know the function lsqnonlin in matlab I would like to know if there is an equivalent method I can implement in LV.
11-23-2017 11:39 AM - edited 11-23-2017 11:41 AM
@Bob_Schor wrote:
Yes, it is possible to do non-linear least-squares fitting using LabVIEW. It is also possible to do this in Matlab, C++, Fortran, Pascal, Python, and a whole host of other languages.
Don't forget paper&pencil 😄
michele87 wrote:The form of this equation look something like R=SQRT(A^2+B^2/C^2+D^2)..only far more complex.
In what way is it more complex (more parameters, more terms). Why can't you show is the actual model equation. Looks almost like a Lorentzian with an offset and negative amplitude (see also).
@michele87 wrote:
The idea behind this is that I know all but 1 of the parameters on the right hand side terms and I would like to have an initial guess for the parameter unknown to obtain the value of R that is closest to the experimental value.
So basically you only have a single fitting parameter at the end. This seems trivial, you could just do a newton-raphson, for example. How accurately do you know the other parameters? If the model is well behaved, you might as well fit for all of them simultaneously and see how well the results agree with your assumptions.
michele87 wrote:I would like to use a fitting function (I am thinking to a non linear least square on the top of my head) to run this iteration process and obtain a good approximation of the unknown value.
LabVIEW is a great choice for nonlinear fitting. Start here for some ideas. If you get stuck, come back and ask more specific questions, attach some data, or even attach your VIs. We'll make sure you succeed! 😄
11-23-2017 12:20 PM
Hi Altentbach,
thank you for your reply, yes I can show you how the function looks like..and it is pretty horrible
In this, I know everything except zl that is the value I am trying to measure.
Unfortunately, I do not think that this is trivial because zl is not a constant with frequency, however I can give a good guess on how the shape of this function.
I solved already this problem expliciting the previous equation as function of zl (this can be done quickly with matlab). However, that is not a practical approach in the real world because than zl would be function of R^3 that is affected by various source of errors.
Therefore I am looking to use an iterative approach because it might be more practical to analyse experimental data.
Do you think I could use the non-linear curve fit VI to solve this problem? I have come across a few examples on the LV help however I am a bit confused on how to implement it.
I will have a look to the nonlinear fitting post and come back as soon as I have a clearer idea on how to proceed,
Thanks
11-23-2017 02:28 PM - edited 11-23-2017 02:32 PM
@michele87 wrote:
I have used fitting functions before, but this problem consists in starting from an initial guess to find the value of my unknown parameter that minimise the error between the experimental data and the model and this problem is new to me.
Hmm -- it seems to me that all of the nonlinear Least Squares routines I've used involved "starting from an initial guess". The method of Least Squares is precisely to "minimize the error between the experimental data and the model" (by finding those parameters that make the sum of the squares of the differences between data and model as small, or "least", as possible).
Look at Mathematics, Fitting on the Block Diagram Palettes.
Bob Schor
11-23-2017 08:24 PM
@michele87 wrote:
In this, I know everything except zl that is the value I am trying to measure.
Unfortunately, I do not think that this is trivial because zl is not a constant with frequency, however I can give a good guess on how the shape of this function.
That is such a complex and hard-to-read Equation, with no notion (on my part) about what are input and output variables, what is "experimental data" (being fit), what the model represents, etc. And now you say that the component zl being estimated is not a constant, but a function of frequency! ??? I don't see Frequency anywhere in your equation!
I'm intrigued that you mention R^3 in your post. This suggests (to me) that R is a Radius of a point in 3D space, or the radial component (in spherical-polar coordinates) of a 3D cartesian vector. Are the various quantities under the radical (hard to read as the type is so small and everything is in italics) X, Y, and Z components? I can't easily read the subscripts ...
I don't think either Altenbach nor I would be "frightened" if you provided more information about this equation, even perhaps a citation to a paper or two (or a Web site) where this Equation appears and is explained. The more we know about what you are doing, the more helpful we might (speaking for myself) be able to be (I have no doubts that Altenbach can be helpful ...).
Bob Schor