Lorentz fit of a curve with Lev-Mar

Hello everybody! I am trying to set of data to a Lorentz curve to calculate a Q value (resonance.) I found a program on a thread from this forum that appears to work with the sample data set from the thread. However, when I try to run the program using my data set with known fitted coefficients as the initial guesses, we get an error in the Lev-Mar sub-VI -- something like “the input matrix is singular”. There’s a screenshot of my data in in the attached zip folder, as well as the text file containing my data.
My data curves down (reaching a minimum) instead of up, as in the sample data set, but it seems like that should be accounted for by the different initial guesses. I am thinking that something else is going on; hopefully it is something simple that I am just missing. Any help y'all can provide would be greatly appreciated!
Thank you!
Attachments:
Lorentz Fit.zip ‏1992 KB

Hello Lynn,
Yes, there are quite a few potential peaks in that data set. The peak you identified was the one that we are trying to fit (The peak should be trimmed by the cursors.) We used origin to fit that same peak in order to get the initial guesses for the coefficients in the screenshot. When it runs, we get the error message: "Error -20041 occured at NI_Gmath.lvlib: Nonlinear Curve Fit LM.vi:2 Possible reason(s): Analysis: The system of equations cannot be solved because the input matrix is singular." 
Thanks!
-Garrison

Similar Messages

  • Curvefit of the reflectivi​ty with Lev-Mar

    Hello,
    I am a beginner with Labview and I need your help, I recuper the data of the reflectivity from the spectrometer (3648 points) and I am going to make the fitting to extract information about the thickness and refractive indices n and k (k in the general case it will be zero because the materials used are oxides and I work in the visible range.
    I want to use the model of Lev-Mar but I have the problem with the model, i have used the formula node to write the eqaution of the reflectivity, and currently I am block.
    Data.txt
    column1 = Lambda
    column 2 : Reflectivity
    the substrate is Pyrex  ; n= 1,47
    the thin film is Ti-Nb, the index is like that of the titane(Antase) : ñ = 2,561 + i2,488
    Thank you very much.
    Nb: i know my english is so bad
    Attachments:
    fit1.png ‏36 KB
    fit2.png ‏30 KB
    Data.txt ‏51 KB

    Thank you very much Lynn,
    I did what you told me to do and it works a better,
    I would like to know if you can help me, I have the values of the reflectivity R as a function of the wavelength (lambda) but the indices " n "  and " k " are also a function of lambda.
    R = (n,k,d,lambda )   and  the dispersion equation n(lambda) and k(lambda)
    With the curvefit Lev-Mar is possible to define these parameter ? if you have ideas that will be cool

  • Curve Fit of ODE, should I use Lev-Mar or Constrained Nonlinear Optimization?

    I wanna do a curve fitting of differential equations, following is the equations:
    dx/dt = u*x-a*x
    ds/dt = b*u*x+c*x
    dp/dt = d*u*x+e*x+f*p
    and u = um*s/(km+s+s^2/ki)
    I've tried "nonlinear curve fit( Lev-Mar)", but I met difficulties when writing the f(x,a) of Lev-Mar.
    Then I tried "Constrained Nonlinear Optimization", I found that the example "Estimate Nonlinear Spring Constant.vi"
    in the "labview\examples\math\curvefit.llb" was similar to the fitting I tried to do, but there was only one parameter
    need to estimate in this example,but what I need is to estimate 3 parameters.
    However,I modified the example to my equations, it failed again.
    How can I achieve this? is it possible to do this fit only using Labview VIs or need Matlab Script Node?
    Any help will be appreciated.

    I forgot to mention that in the equations above,  a,b,c,d,e,f is constant,
    and the data of x,s,p corresponding with the data of time is already known,
    and which parameters I wanna identify is um,km,and ki
    帖子被myafu在12-22-2006 01:33 AM时编辑过了

  • Problem: Fitting Lev-Mar with Error Function

    Hi everyone,
    I have very little experience with LabVIEW and I'm trying for the first time to do some NonLinear Curve fit for some data I have.
    I've searched in forums for almost a day and couldn't find what I need. The problems are:
    1) I need to fit a function of the following type: P = Po/2 - Po/2*erf(sqrt(2)*(x-xo)/w) , where Po, xo and w are my parameters.
    But in my error2.vi I cannot link my y=sqrt(2)*(x-xo)/w  variable of the erf function to the input, because the erf.vi does not accept 1D array as input and doesn't give that as output as well. The output thing is another problem, since the input of F(x,a) needs to be a 1D array.
    2) I read about the Lev-Mar NonLinear CurveFit VI and I think I got what needs to be done. However, a I was having problems in wiring my Static VI Reference to the F(x,a) input in the Lev-Mar VI and it didn't give me a broken wire only when I made de Reference a "Strictly Typed VI Reference". What does that mean? Why did it only work with that?
    I know these are some pretty basic doubts, but I've been trying to understand it for quite some time and couldn't get this done.
    Thanks.
    PS* The fitting function (subvi) is the error2.vi file.
    Solved!
    Go to Solution.
    Attachments:
    error2.vi ‏13 KB
    FittingGaussianKnife.vi ‏15 KB

    Try this. Seem to work  just fine (LabVIEW 2013).
    (don't try to graph the best parameters, graph the best fit output!)
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    FittingGaussianKnife_MODCA.vi ‏17 KB
    error2_MODCA.vi ‏14 KB
    erfit.png ‏40 KB

  • Varying Lev-Mar init. conditions causes wide change in fit coeficients.

    Hey, I'm trying to use the advanced Lev-Mar fit vi to fit an exponential decay with an offset. I noticed that when I vary the initial condition for the time constant by 5% I get significant changes in my fit coeficient for the same parameter. However, when I multiply my input Y values by 10^4, the fit coeficients are more robust and change little with initial conditions that vary more than 10%. Also, the values now seem to match well with values I obtain when I perform the same fit in the Origin plotting program. Why is this? All my values are in double precision so I don't see how this could be a precision issue.

    The Lev-Mar has a well-known "bug" in the termination condition IF you fail to wire the "standard Deviation Input". In this case, the standard deviation is taken as 1, which is fine except for the case where your y-data is very small (e.g. all in microvolts or nanovolts). In this case, the function is considered converged after one iteration using the initial guesses.
    You have two options:
    (1) (not recommended) Edit the Lev-MAR.vi and make the diagram constant in the bottom center much smaller.
    (2) (RECOMMENDED!) Always wire a "standard deviation input array". In your case, just create an array with equal size as your data, initialized with numbers corresponding to the noise in your data. It does not need to be accurate, you could just take it as e.g. 10E-4 to 10e-6 times your y-range (y-max minus y-min).
    LabVIEW Champion . Do more with less code and in less time .

  • Trying to fit a curve with restrictions

    I am trying to fit my experimental data with my own function y=a*exp(-x/b)+(1-a)*exp(-x/c) and I want the "a" paremeter to be >0 when doing the fitting.
    Is there anyway to do so?
    Thanks!

    sleepyqueen wrote:
    what if I use 7.0 vision? Is there any way to realize Constrained Nonlinear Curve Fit use Labview 7.0?
     Yes, but you have to do it all yourself from scratch.
    LabVIEW Champion . Do more with less code and in less time .

  • Please help on this Lev-Mar problem

    Hi,
    I have two acquisition data sources that need
    to be fitted. Then the fitted parameters are
    passed along with data for further processing.
    As the data is heardware generated, I made a
    similar 'signal generator' to present very closely
    the problem.
    ===Please see the attached vi file===
    As you can see, these two Lev-Mar's function
    / derivatives are obviously different. We can edit
    the fuction / derivative node. But the problem
    is that when one is edited, the other changes too.
    Anyways, we can NOT have two different functions.
    My question is: How to have two different function
    / Deveritives here?
    By the way, how to replace the MatLab box into
    function node in my attached example?
    I can 'wire' the out
    put to next if it's a
    function node. It says the type of variables are
    different (output is a real instead of array).
    Attachments:
    Lev-Mar-Question2.vi ‏99 KB

    You have a few options for multiple function/derivatives.
    1. If you can express the model functions using the formula string syntax, then you might consider using the "Levenberg Marquardt.vi". Unfortunately the Levenberg-Marquardt.vi does not allow the specification of the derivative of the model function and always uses numerical derivatives. It is also somewhat slower than the "Nonlinear Lev-Mar Fit.vi".
    2. You could also save a copy of the "Nonlinear Lev-Mar Fit.vi" using a different name, and also the "Lev-Mar ABX.vi" and "Target Fnc & Deriv Nonlin.vi" with different names. Then you would have a different set of VIs to implement the curve fitting on two different models. This is ugly, but would work.
    3. You could modify the "Nonlinear Lev-Mar
    Fit.vi", "Lev-Mar ABX.vi", and "Target Fnc & Deriv Nonlin.vi" to accept/pass VI references. The "Target Fnc & Deriv Nonlin.vi" would then perform a call by reference to a VI that you wrote implementing the current model function.
    To replace the Matlab script node place the formula node inside a for-loop. The for-loop will auto-index the x and t arrays, and auto-build the y-array.

  • Lev mar parameter min value

    When I use the Lev Mar curve fit, I get an error that says at least one of my input parameters is NaN or Inf.  There is a place in my fitting equation where I divide by the parameter and take the square root, so if it was either zero or negative, this would not work.
    Is there a way that I could force Lev Mar to not choose values of 1 or zero for this parameter?  My initial guess is very small (on the order of 10^-4), but this parameter is time, so it should not be negative or zero anyways.

    What is your LabVIEW version? The function has been renamed to "nonlinear curve fit" many versions ago.
    There is a constrained nonlinear curve fit that lets you set parameter bounds. Use that instead.
    Can you show us your code and some typical data? If you calculate the model with your paramter guesses, does it look anything like the data?
    LabVIEW Champion . Do more with less code and in less time .

  • A confusing lev-mar error

    I am trying to fit a Lorentzian to some acquired data using the lev-mar function, and it returns the error "wrong model equation". I know for a fact that the data has a lorentzian shape because I wrote a little vi to fit it manually using the exact same equation. Does anyone have a suggestion as to what to do next, or at least what the "wrong model equation" error really means? Thank you.
    JPC

    The error refers to a syntax issue with the "model description" input.
    This input is a cluster of three strings: model, which is the actual equation (Ex: a+b*x+c*x^2); paramters, which are the solvable variables (a, b, & c in the previous ex.) inputted as an array of strings; and the independent variable (x).
    All 3 parts of the model must match exactly (e.g. you can't have 3 variables in the model and 1 in the parameters, and if you designate x as the independent variable, there must be an x in the model equation).
    Additionally, the model equation follows standard LabVIEW formula node syntax, except there are no input variables designated ("y=x+1" won't work but "x+1" will) and you don't need a semi-colon terminator.
    Let me know how it goes,
    ~j5
    2006 Ultimate LabVIEW G-eek.

  • How to constrain parameters in Lev-Mar?

    It's a common case for non-linear fitting.
    How can it be done in LabView's Lev-Mar?
    Thanks.

    The provided LabVIEW implementation does not contain options for parameter bounds.
    One solution would be to re-parametrize your code in terms of unconstrained variables that cause a constraint on your original parameters.
    Some transformations for one-sided or two-sided parameter bounds are given here:
    http://www.id.unizh.ch/software/unix/statmath/sas/sasdoc/stat/chap19/sect41.htm
    The link also lists references with more details.
    LabVIEW Champion . Do more with less code and in less time .

  • Lev-Mar template missing

    I am trying to fit A*sin(w*t+phi) to some noisy data (amplitude, frequency, and phase are all to be detrmined from the matched sine). When I looked at the Lev-Mar fitting VIs I could not locate the template for the LM model function and gradient VI template mentioned in the Help file. labview\vi.lib\gmath\opti.llb\numerical is empty. (Help says this template should be there). The figure in the help file shows a cluster called Output Control as an input to the VI, but does not specify the elements of the control. I also could not find a way to put the formula into the String Formula version. Is there a listing of the available functions and syntax? The help did not seem to lead me to it.
    LV8.0.1 on Mac OS X
    Maybe it is just too late on Friday afternoon.
    Lynn

    Sarah, Christian,
    I had looked at that link and several others. I was hoping to find some reference where someone had made some practical suggestions reagrding optimizing the initial guesses, or at least some clues as to how to go about it.
    My data has a frequency range of about 2.5:1 so I was hoping I could just set the initial guess at the middle of the range. In my testing an initial guess 20% above or below the actual frequency resultis in erroneous values about 80-90% of runs with noise at 10% of signal amplitude which is better than the real data. With initial amplitude and phase equal to the data parameters and initial frequency guess at 1.2 times the actual I recorded two runs with the fit frequency at 99.9%. Eight others produced: 160%, 180%, 210%, 160%, 160%, 130%, 60%, and 160%. With the initial frequency at 80%, the results were somewhat worse.
    My suspicion is that because the partial derivatives of the model equation are also sines and cosines, the algorithm tends to find some kind of local minimum and converges to that even though it is a really poor fit.
    Here is my modified Lev-mar VI and the simple sine model VI (LV8). The default values are fairly typical of the data sets we will be getting.
    Thanks for the help.
    Lynn
    Attachments:
    Nonlinear Fit Lev-Mar.Berry.vi ‏41 KB
    simple sine model.vi ‏21 KB

  • Gaussian Peak Fit and Nonlinear Curve Fit on small data differ from Origin Peak fit

    Hi all,
    I am developing a program in which I have to fit Gaussian curve on only 4 or 5 data points. When I am using Gaussian Peak Fit or Nonlinear Curve fit, it linearly connects all the points while other fitting software like Origin is fitting Gaussian curve on the same set of data I have attached two images One is from Labview with Gaussian Peak Fit and NonLinear Fit and other is from Origin.
    Data is
    X                       Y
    799.09857        257
    912.25256        641
    1026.00366     1516
    1137.92871     1118
    1253.43713     329
    Labview user
    Solved!
    Go to Solution.
    Attachments:
    Origin_Fit.PNG ‏21 KB
    Labview_fit.PNG ‏15 KB

    That looks like a plot of the input data.
    When I run it with your data I get a Gaussian curve which looks much like your Origin plot.
    The Plot 2 curve is from 128 points equally spaced along X and Y calculated from the Gaussian formula in the LV help using the output parameters from the fit.  Plot 1 is the Best Gaussian Fit output from the fit VI.  It only has five points.
    I used default values for everything except X and Y.
    Lynn

  • How can I add a curve with a different sample rate behind another curve to show it like one in the report

    I saved two curves with different sample rates with signal express in waveform.
    Now I want to add the curves behind and show them in a report. 

    Hello MReizner,
    Both the DIAdem VIEW and REPORT panel use the time information from your Waveform channels (make sure they actually have the waveform symbol, not the numeric data channel symbol in the Data Portal) to plot the data in the same axis system.
    In the example below I have two waveforms, one sampled at 5 Hz and one sampled at 1 Hz, both in the same axis with the same time channel. All I did was drag the data from the Data Portal onto the axis. DIAdem automatically takes care of creating the correct time channel and plotting the data with the correct points if the data is stored as a waveform.
    I hope this answers your question, please let us know if further clarification is required ...
    Otmar D. Foehner
    Business Development Manager
    DIAdem and Test Data Management
    National Instruments
    Austin, TX - USA
    "For an optimist the glass is half full, for a pessimist it's half empty, and for an engineer is twice bigger than necessary."

  • Several curves with several scales on the same graph

    Hello,
    I am currently working on a project which include a data acquisition VI. I would like to display two curves with two different scales (0 to 1 and 0 to 200) on the same graph.
    I have been trying nearly all the options in the properties menu, I can not find anything that corresponds to what I want.
    Do you know how to do such a thing?
    Thanks in advance,
    Gabriel.
    Solved!
    Go to Solution.

    Right click on the existing scale and click Duplicate Scale.
    EDIT:  I should add that you'll need to set ActYScl through a property node to switch between the difference scales if you want to run operations on them.
    --Using LV8.2, 8.6, 2009, 2012--

  • Sycing a Blackberry Curve with Outlook Calender 2007

    Hi I have been trying to sync my BB curve with Outlook, have read all the forums, reinstalled my operating system, downloaded Desktop manager 4.2 and then back to 4.7, upgraded my operating system and I have tried all the applications inside desktop manager including one way, two way, one way from device, one way from computer.
    I suspect that there may be a calender entry dialogue box open, so I tried to close and clean everything from the calander on the desk top.  The memo, tasks and contacts all syc fine -- when in gets to calender it say "one moment please" and then it does not syc. It does not show up in the sync report as well -- any thoughts

    If you are having errors in your Calendar or Address Book on your BlackBerry, and you wish to delete the entire Calendar (or Address Book) database on your BlackBerry, follow the directions below. Make certain you have a good copy of your Calendar or Contacts elsewhere, as this procedure will complete delete ALL Calendar entries and/or Address Book entries on your BlackBerry.
    1. Open Desktop Manager on your PC.
    2. Open up Backup/Restore > Advanced.
    3. From Advanced you'll see a split pane screen. The left pane is what is going to be backed up from your device and the right is a list of the currently existing databases.
    3. Highlight on the right side your Address Book database (or your Calendar database) and click the arrow in the middle pointing to the left. This will copy the information over and prepare it for back-up.
    4. Once the back-up has completed, hit the Clear button at the bottom to erase and clean out the entire address book database (or Calendar database).
    5. After it's finished, it will ask you if you want to save the back-up you've created, say yes and check the device to make sure the address book (or calendar) has been properly cleared out. Now, resync the necessary contact information and you should be set to go.
    Message Edited by urumilton on 01-14-2009 10:28 AM
    If I help you with any inquire, thank you for click kudos in my post.
    If your issue has been solved, please mark the post was solved.

Maybe you are looking for

  • Export of a table with BLOBS

    I have an application on our/your hosted environment. in two of this tables are stored some documents (pdf,doc) and pictures. For deploying my application to a local environment I can use application-export, image-export (for some global pictures), C

  • Suite CS3

    I've been attempting to install the Adobe Suite CS3 on my Mac OS X Tiger 10.4.11. It installs fine. Any time I try and run Illustrator, it gives me an error message that says "Missing BPS Pencil Tool" and then it crashes. I have searched multiple for

  • Blackberry link OSX 1.6 Snow Leopard

    Hi, Got my new Z10. I can only download the newest version which requires Mavericks (10.7). Is there a version for 1.6 available? Regards Michael

  • I prepurchased "There Goes Your Money" and cannnot find it in my cloud. It shows purchased in my history, but I have not downloaded it. HELP!!

    I prepurchased Virtual Riot "There Goes Your Money" in August and got notice today that it is available to download. It is not in my cloud to download yet shows purchased in history when I pull up the album under my Apple ID. How do I download the al

  • How to create Mail Folders?

    Question Does anyone know how to create mail folders for oganizing the inbox? I can't figure it out, but likely, the answer will be "you can't". I'm not using an IMAP mail host, I have a pop account with Yahoo!Mail. Any help is appreciated... Thanks.