Constrained nonlinear curve fit can properly handle the function like ln(1+b(x-xc)/a) ?

Hi all,
I met some problems about using constrained nonlinear curve fitting vi. It seems to me that this vi can't properly deal with the function like ln(1+b(x-xc)/a), a,b, and xc are the parameters, and b is in the range of 0 and -1. The reason I said that is as I used the other nonlinear fitting function in the other software, like Originlab, the fitting function can work properly.
The error message from LV occurs as 1+b(x-xc)/a is less than zero. 
However, due to a,b are both adjustable parameters, how could this situation happen ?
Now I attach the vi files. The attachment includes main vi, mathmatical formula, and an input XY txt file.
I appreciate any help or suggestion from you!!
Here is the error message
Joy
Solved!
Go to Solution.
Attachments:
LN-fitting.vi ‏21 KB
LN-fittingmodel.vi ‏18 KB
Book2.txt ‏1 KB

Thanks for reply. whitenoiz 
Actually I have more than 100 XY data set to test my vi. Some of the data set can be fit flawlessly. And the best fit parameters obtained from my vi are exactly the same as those from other analytical software, like OriginLab. In this case, I know my vi is valid. And in this scenario, I also found 1+b(x-xc)/a is always larger than zero with the best fit parameters (a and b). However, for certain XY data set, the error message will pop up if I use LV built-in vi, but I still can obtain the best fit parameters with OriginLab. And then I realized that error message always pops up as 1+b(x-xc)/a is less than zero, which it means to me that as LV built-in vi handles this type mathematical function, this built-in vi will encounter some difficulties. 
I will step through my code, and also focus on the Matrix Left DivisionMV.vi, try yo find where the problem is.
Best regards,
Joy

Similar Messages

  • Constrained Nonlinear Curve Fit VI: Termination Revisited (LabVIEW 8.5)

    Hello:
    In the Constrained Nonlinear Curve Fit VI, the Help for the VI states that if the number of iterations exceeds max iterations specified in the termination control, the fitting
    process terminates. Would this not indicate that if the above condition is met, the number of iterations recorded (an output of this VI) should be equal to the max iterations specified (since the VI is exits at this point).  I believe I have seen situations where this condition is met, yet the number of iterations recorded is greater than the max iterations I have specified in the termination control.  Has anyone else seen this?
    Thanks,
    Don

    Don,
    Just wanted to clarify the termination criteria for the nonlinear curve fitting routines.  There are two criteria used to terminate the fitting process:
    "max iteration" and "tolerance".  The main while loop terminates when either of these conditions is met, so:
    IF( (current_iteration > max_iteration) OR (current_tolerance <= tolerance) ) THEN (terminate loop)
    "current iteration" is just the current loop counter(starts at 1 for the first iteration).  This term is mainly a guard against having the fitting process run too long.
    tolerance is computed as the relative change between the current and previous weighted least squares values.
    Let wls = SUM_OVER_ALL_X( weight(x)*(f(x,a)-data(x))^2 )
    current_tolerance = ABS(current_wls - previous_wls)/(ABS(current_wls) + machine_epsilon)
    where ABS indicates absolute value.  Adding machine_epsilon to the denominator is just a guard against division by zero.
    For the bound nonlinear curve fit VIs, if the "method" input is chosen to be LAR or bi-square, then wls is defined as:
    wls = SUM_OVER_ALL_X( weight(x)*reweight(x)*(f(x,a)-data(x))^2 )
    where reweight(x) is a term reducing the weight of high-leverage data points.
    For both the constrained and unconstrained fitting routines, if the weight input is unwired then all points are considered to have a weight of 1.
    Christian has nicely covered the difference between the number of iterations and the number of function calls.  If your
    When the fitting process terminates the best result obtained so far is returned.  As you noted, this may be a good result, although the algorithm may not have completely converged yet.
    -Jim

  • For "Nonlinear Curve Fit.vi", what does -20068 mean and how can I avoid it?

    Hey guys,
    I am trying to fit an oval in a set of 2D data points, which represents a partial oval.
    So I am trying to see if "Nonlinear curve fit.vi" would work in the situation.
    However, sometimes that math VI would give me an error -20068 and would return incorrect fitting parameter.
    I can't figure out what condition would return that error so can you tell me
    what the cause is and how I can avoid that error?
    You can run the attached LabVIEW 2013 VI and see the error.
    Attachments:
    ellipse fit data.zip ‏41 KB

    jcyth wrote:
    The model is a result of solving the ellipse equation for y, 
    (x^2)/(a^2) + (y^2)/(b^2) = 1
    So I don't really see a simple way to make the negative values less likely...
    but maybe I can use "Constrained Nonlinear Curve Fit" where I can bound the parameters then?
    This is slowly drifting away from a LabVIEW problem but any help is appreciated! 
    The solution is to re-parameterize the problem and solve for something much less pathological
    You can directly fit for the above formula by providing x&y for all points to the model and optimize the four ellipse parameters until you get an array of all ones.
    I quicky coded this in the attached example and it seem to be quite stable, even with lots of noise.
    See if this works for you.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Ellipse FittingMODCA.zip ‏40 KB
    FitEllipse.png ‏26 KB

  • Nonlinear Curve Fit VI keeps all initial parameters

    My question is about fitting a curve with nonlinear curve fit VI. The fitting function has the formula like
    A/((x/I)^p-C)+B, where fitting parameters are {A, B, C, p, I) and variable is x. I tried to use both Nonlinear Curve Fit VI and Constrained Nonlinear Curve Fit VI, but neither gives me fitting parameters other than what I input as the initial parameters. As an example I am attaching the data set file where the fist column is x and second column is y. The initial fit parameter set is {2,0,1,2,90}. It would be appreciated if someone could point out how I use either these fitting function to get the best fit.
    Attachments:
    60QR.zip ‏1 KB

    Actually my LV code is quite simple and has nearly nothing more than the nonlinear curve fit vi itself. Anyhow I am attached my code here so that you could at least run and see what my question is about. The caller VI is "Curve Fitting.vi". The subVI inside it that calls the curve fitting function has two flavors inside. What is enabled uses the contrained nonlinear curve fit vi while the other one that is currently disabled, calls the function of nonlinear curve fit vi.
    Thanks.
    Attachments:
    Curve Fitting with a Nonlinear Model.vi ‏29 KB
    Curve Fitting.vi ‏17 KB

  • How to use the parameter "data" in the vi of Nonlinear Curve Fit

    I used "Nonlinear Curve Fit" to do state estimation. If I make the number of unknows a constant number, it is fine to code the fitting model for f(x,a). But if I want to code the number of unknows as a variable, how can I do this?
    Maybe "data" should be used here. But I just could not find any examples talking about how to use "data" here.
    Thanks.

    Hey hilary,
        Have you looked at the LabVIEW help for the Nonlinear Curve Fit VI?  Which version of LabVIEW are you using?  In mine, the VI is polymorphic, and you can declare the formula to be a formula string.  Then it provides pins to enter the input parameters programmatically.  Perhaps you could post a screenshot of how you are currently using the VI, and we could help more.
    Brian B
    Field Sales Engineer
    Tennessee/Southern Kentucky
    National Instruments

  • Nonlinear Curve Fit LM Formula String in Labview 8

    hi, guys. I write a vi which use Nonlinear Curve Fit LM Formula String. When I run it ,the program says "Syntax error of parser." and I don't know what's wrong with it, so help me,Please. By the way ,you can fill the arrays as you wish.
    帖子被trinight在02-11-2006 07:51 PM时编辑过了
    Attachments:
    curve fitting.vi ‏16 KB

    You MUST wire initial estimates for the parameters. Attached modification works just fine.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    curveFittingMOD.vi ‏17 KB

  • Nonlinear Curve Fit and using static data

    I am trying to fit data to a 2D function using the Nonlinear Curve Fit VI in Labview 8.2.1, but I would like to also include 2 parameters that I don't want to be optimized.  I cannot directly use constants since every time I run the fitting I need to change the 2 parameter values.  I tried to modify the example by Altenbach according to my own application in the link below. 
    http://forums.ni.com/ni/board/message?board.id=170&message.id=230831
    I think the problem is that I don't completely understand how to use the static VI reference with the Nonlinear Curve Fit VI?  It looks like there is a static data control that I could use to add additional parameters, but I am not sure?  I can get Altenbach's code to work if I change the function to something different, and even if I change the number of inital fitted parameters.  I just can't figure out how I can add parameters using a control that will not be optimized.  I can attach an example, but it is very similar to Altenbach's code except the function is different, and I am trying to add additional parameters that are not optimized.  Thanks for any help.
    Kevin Baker 

    Thanks Trey.  I am sorry I didn't make it clear what I was talking about before.  I am attaching an example that will hopefully clarify what I would like to do.  When I try to pass the static reference to the Nonlinear Fit VI it says gives me a broken wire and says "function conflict".  I am assuming the problem is that I inserted another control to the VI when I wasn't supposed to.  I just don't know of any other way to pass data into the VI, and still have the Nonlinear Fit VI still work?  What is the "data" control in the Nonlinear Fit VI used for anyway?  It seems that that it was want I need, but I don't know how to use it?  Thanks again for any help.
    Attachments:
    Fit equation.vi ‏15 KB
    general lorentzian.vi ‏26 KB

  • Nonlinear curve fit help needed

    I am in need of some help trying to fit a set of data that requires the use of nonlinear curve fitting.  I have attached a txt file containing the data that needs to be fitted.  The first row contains the x-axis values while the second row contains the y-axis values.  The model for this set of data can be described by a single parameter, A, for the first five data points.  The remainder of the data points can be described by the model A+A1*exp((0.4-x)/A2), where A, A1, and A2 are all parameter.  As you can see the two models share the parameter A.
    I have determined some initial values for each of the parameters: A=176.32, A1=2133.4133, and A2=1.4936.
    I have spent the last couple of days trying to figure out how to use the Lev-Mar nonlinear curve fit vi but have had little success.  I have been doing LabVIEW programing for many years now and I have never felt as lost as I do now trying to understand how the Lev-Mar nonlinear curve fit vi works.  Any help you can provide with my data fitting would be greatly appreciated.
    Thanks.
    -Alonzo
    Solved!
    Go to Solution.
    Attachments:
    Data.txt ‏1 KB

    I think the problem is that the first 5 points are not part of the data sent to Lev-Mar.  Because of this the fitting process fits the remaining data very well, but the constant term is able to freely move.  I modified the model function to output A for the first 5 terms, and the complete function for the rest.  The offset found is now more reasonable.
    Also, your quote your model to be A+A1*exp((0.4-x)/A2), but what is implemented in the model VI seems to be A+A1*exp((x-0.4)/A2).
    -Jim
    Attachments:
    ExponentialFunction.vi ‏19 KB
    FitExponentialExample.vi ‏24 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

  • Nonlinear Curve Fit Error

    I am trying to get a multi-dimensional fit working by using a nonlinear curve fit VI and everytime I run it I get an error saying that my samples need to be greater than 0. The specific error message is: "Error: Analysis samples need to be > 0." Does anyone know what is wrong? I have tried to reinitialize my input parameter array to zero, recompile the VI, etc. and still get the same error regardless.
    I have attach all my VI's.
    Thanks,
    Ynessa 
    Attachments:
    Multidimensional Fit.zip ‏65 KB

    ytran wrote:
    I am farely new to labview and have not figure out the best way, so that my diagrams stay smaller since my width and height are farely large. What do you mean eliminate the local variables in the loops of the model? 
    In the model, you have a hidden indicator called pixel size, which you write once outside the loop and then continuously read over and over again with every iteration of the loops via local variables. SInce the value does not change during the execution of the loops, reading the same indicator over and over is just a waste of efforts. Why involve the UI if the valie is right there in the wire?? The correct way would be to delete that indicator and the local variables and simply connect all by wires.
    Did you understand my other comments?
    ytran wrote:
    The typical values for the controls are as follow:
    Pixel Size (um) = 5.2
    x0 (mm) = 640
    y0 (mm) = 512
    Focal Length (mm) = 1000
    Wavelength (mm) = 561
    Beam Diameter = 1
    Amplitude = 100
    Background Amplitude = 10
    Are all of those fitting parameters or are some of them constant and known?
    LabVIEW Champion . Do more with less code and in less time .

  • Constrained Nonliner Curve Fit Error -20003 help

    Hello.
    I use Constrained Nonliner Curve Fit.vi to fit a customed function, just in the following picture 1. The initial paraments are exactly right, but it always stopped by a error -20003,it says "The number of samples must be >0",just as the picture 2.
    What should I do to correct it? Thanks!
    Attachments:
    1.png ‏32 KB
    2.png ‏9 KB

    Can you attach your code and some sample data? How big is the [X] array? The [a] array?
    Does it work if you remove the partial derivatives calculation? (LabVIEW will automatically substitute numerical derivatives).
    (The way you index into [a] seems incredibly convoluted. Couldn't you simply reshape into four columns and autoindex on a FOR loop?)
    LabVIEW Champion . Do more with less code and in less time .

  • Since the update, some yahoo groups can't handle the format while others can.

    I belong to many yahoo groups. I use yahoo for email. Most of the groups can handle posts made since the update, but one of them bounces my emails saying the site can't handle the new format.
    == This happened ==
    Every time Firefox opened
    == since I updated Firefox, within the last month.

    Let me know if this doesn't work; this is how it works on ICS on a Bionic, and it may be different on a Razr/Maxx with JB:
    Highlight the song you want to copy
    At the bottom of the screen, there should be a 'copy' button (looks like two pages on top of each other), press it
    At the top of the screen it should say '1 copied', press it
    You should get a pop-up to choose between Device Storage and the SD Card, press Device Storage
    Scroll to the Ringtones folder, press it
    At the top of the screen on the right-hand side, you should see the word Paste, press it
    And you're done (I hope!).

  • How can I create the component like ComboBox in flashlite2.0 ?

    How can I create the component like ComboBox in flashlite2.0
    I'm a new man, please gave me an example!
    Thanks.

    I don't see anything special about the play button in MPMoviePlayerController....
    the "glowing" effect icons are all standard UIBarButtonItem objects:
    http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIBarBut tonItem_Class/Reference/Reference.html

  • Can anyone explain the function BAPI_PROJECT_GETINFO

    Hi
    Can anyone explain the function BAPI_PROJECT_GETINFO.
    Can anyone explain the import and export parameters of this function module.
    What is the logic.
    I'm getting the output as 'No data record exists'.
    This is immediately required.Please help me.
    Thanking you
    Chandrika.

    hi
    good
    go trhough this
    Short text
    Read detailed information for work breakdown structures
    Functionality
    You use this method to read detailed information about project definitions and the WBS elements of certain projects from the system.
    Notes
    Enter the project definitions and/or the WBS elements, which you want detailed information about, in the parameter PROJECT_DEFINITION or I_WBS_ELEMENT_TABLE respectively.
    If you only enter project definitions, the details of all the WBS that belong to the project definitions are read including the hierarchy. If you explicitly enter WBS elements, only these are read.
    Messages are returned in Return parameters. For information about the return values and their meaning, see the parameter documentation.
    Parameter
    PROJECT_DEFINITION
    WITH_ACTIVITIES
    WITH_MILESTONES
    WITH_SUBTREE
    E_PROJECT_DEFINITION
    RETURN
    I_WBS_ELEMENT_TABLE
    E_WBS_ELEMENT_TABLE
    E_WBS_MILESTONE_TABLE
    E_WBS_HIERARCHIE_TABLE
    E_ACTIVITY_TABLE
    E_MESSAGE_TABLE
    thanks
    mrutyun^

  • Can anyone explain the functionality of FM f4ut_parameter_get_values ?

    Can anyone explain the functionality of FM f4ut_parameter_get_values ?
    This is used in search help to retrive values from screen.This doesnt seem to work for me

    hi,
    check this
    F4UT_PARAMETER_VALUE_GET
    Short Text
    Standard search help exit for determining contents of a srch help par.
    FunctionalityBy calling this module in a search help exit, you can find out the current contents of a search help parameter . To do this, you must pass the name of the parameter in PARAMETER.
    You must distinguish between the parameter contents that are used in the selection process of the input help process and the parameter contents that are determined by the selection process and the user selection.
    Parameter contents that are used in the selection process are default values of search help parameters, values that are included in the input help process by attaching the search help to the screen from field contents of the screen or its module pool, and possibly complex restrictions made by the user in the dialog box for restricting value. Such parameter contents can also be included in the input help process by the search help exit itself.
    The contents of the specified parameter used in the selection process are stored as complex restrictions in SELOPT_TAB after the call. If exactly one value is defined by these complex restrictions (for example if the restrictions have exactly one row and if SIGN = 'I' and OPTION = 'EQ' for this row), this unique value can be found in VALUE.
    Parameter contents that are determined by selection process and user selection are the parameter contents that are shown in the dialog box for displaying the hit list or returned on the screen. They are managed by the F4 processor in RECORD_TAB.
    This module enables you to transfer the information about the specified parameters from RECORD_TAB to RESULTS_TAB in edited form.
    Pass the name of the field of RESULTS_TAB that should contain the contents of the parameter to the function module in parameter FIELDNAME. If the row type of RESULTS_TAB is elementary, pass the value '*' in FIELDNAME. The rest of RESULTS_TAB is not changed. The values are copied row by row. By removing rows at the end or by adding intiial rows you can make sure that RESULTS_TAB has exactly as many rows as RECOD_TAB.
    Example
    You can find an example of the second kind of use of the module in the search help exit SAPBC_GLOBAL_F4_SFLIGHT of search help SFLIGHT.
    Both types of use can be found in the search help exit SAPBC_GLOBAL_F4_SFLIGHT_MIN_FR of search help SFLIGHT_MIN_FREE .
    Notes
    1. Parameters OFF_RESULT and LEN_RESULT should not be used any more since there are basic problems when using UNICODE. The contents of these parameter are still analyzed when parameter FILEDNAME is initial for compatibility reasons.
    2. Only the dialog box for restricting values can normally produce complex restrictions for a parameter.
    3. If VALUE has the value SPACE, this means that either there are complex restrictions for the parameter or the unique contents are SPACE. SELOPT_TAB must be evaluated in order to determine which of these is the case.
    4. If the search help does not have any parameter with the given name, the exception PARAMETER_UNKNOWN is triggered.
    5. Only parameter contents for the search help displayed in the hit list or the EXPORT parameters of the search help are first managed in RECORD_TAB. If the specified parameter does not satisfy one of these conditions and if parameter RESULTS_TAB is specified in the call, the exception PARAMETER_UNKNOWN can also be triggered. This is not true, however, if results were already entered for the parameter with function module F4UT_PARAMETER_RESULTS_PUT or if space was reserved for the parameter in RECORD_TAB with function module F4UT_PARAMETER_ALLOCATE. The parameter therefore should only be defined if information about the parameter contents are really required.
    6. The header lines of the specified parameter are also transferred from RECORD_TAB to RESULTS_TAB.
    7. The other parameters of this module must be defined as the parameters of the search help exit having the same name, but they are not changed by this module.
    8. RESULTS_TAB should be a standard table.
    9. The contents of the specified parameter in RECORD_TAB are copied to the specified field of table RESULTS_TAB with a MOVE of the correct type. If this is not possible, the target field is assigned the initial value.
    10. If RESULTS_TAB has no field with the name specified by FIELDNAME, only the number of rows of RESULTS_TAB is adjusted to those of RECORD_TAB as described.
    Parameters
    PARAMETER
    OFF_RESULT
    LEN_RESULT
    FIELDNAME
    VALUE
    SHLP
    CALLCONTROL
    SHLP_TAB
    RECORD_TAB
    SELOPT_TAB
    RESULTS_TAB
    Exceptions
    PARAMETER_UNKNOWN
    Function Group
    SF4U
    if helpful reward some points.
    with regards,
    Suresh Aluri.

Maybe you are looking for

  • How to change the port no in weblogic 10.3 server.

    Hi, Could you please tell me the steps,how to change my bea10.3 port no from 7001 to 7002? Thanks Advance.

  • 4G Mi-FI won't connect to printer

    Help!  I cannot connect my new wireless printer (Kodak ESP 7250) to my new 4G MI-FI, although I can connect two of my PC's to it just fine.  I've tried changing the passcode, level of encryption, etc., but to no avail. Help!

  • Graphical performance

    hey, a friend of mine has the new nvidia graphics card in his pro (256) and is getting poor performance in gaming..and other heavy tasks. is this a problem with the drivers? thanks for all your comments

  • JrApache socket shutdown failed[7]: 22, 22 Invalid Argument

    I am getting repeated error log entries that say: [notice] jrApache socket shutdown failed[7]: 22, 22 Invalid Argument Watching the log while I interact with the website I'm beginning to think that this might be related to session variables. Can anyo

  • Debit Card for Family Sharing

    Can I set up family sharing without a credit card? I'm trying to create an ID for & add my son to set up our family sharing, but it says I have to have a credit card, not just debit. Is there a work around for this?... we don't have any credit cards.