How to implement Non linear Curve fitting (lsqcurvefit of matlab) in Labview

Hi Labview Team,
I am looking a way to implement "lsqcurvefit" command of matlab in Labview to do some curve fitting ; basically to  Solve nonlinear curve-fitting (data-fitting) problems in least-squares sense, at present I couldn't find a better way to implement it. Can you please give me some suggestion on this to how to implement this " curve-fitting: on labview.
Thanks,
Ankit Gupta

You did not say you have the mathscript module. Do you? In any case, labview has a rich set of native nonlinear fitting tools. This seems like a better option.
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • Why doesn't my non-linear curve fit finish?

    I am working with an experiment that gives me X- and Y- data that I need to fit to a theoretical model (somewhat involved). I use to do this in matlab using the "lsqcurvefit", which works fine,
    but for varous reasons I need to do this in LabView instead.
    So, first thing I did was to make a vi which is my theoretical model. I throw in my X-data and get the Y data out of it.
    This vi works fine of it's own, but now I want to do my fitting by calling the model-vi from the Nonlinear curve fit.vi. I enter the same initial parameters, termination conditions, upper- and lower boundaries as in the matlab code, but no matter what, after some 100 function calls, the curve fit interrupts and tells me:
    "Error -20041 occurred at NI_Gmath.lvlib:Nonlinear Curve Fit LM.vi
    Possible reason(s):
    Analysis:  The system of equations cannot be solved because the input matrix is singular."
    I have tried to locate the problem at varoious levels but I get confused when I start to look into the nonlinear curve fit vi, I just lose myself in tons of block-diagrams.. Can anyone see what my problem is? I'd sure appreciate it! I added the necessary files. Main vi: langevin fit. vi, then open the data.txt.
    Thanks
    Attachments:
    langevin fit.zip ‏94 KB

    Your model function does not produce anything resembling your data. As a first step, graph the data using your initial guesses, here's how it would look.
    Here' the data and your initial guess on the same graph. You need to find initial guesses so the output resembles your data.
    My best guess is that your model is faulty. It is very hard to debug, because it is a mess: deeply stacked sequence structures and unneeded local variables. Also the model parameter constants should be provided via the "data variant" input instead of a global variable. You have a weird mix of datatypes. Why is half of the stuff EXT instead of DBL for no reason?
    I would also highly advise NOT to color your own VIs light yellow. Don't make them look like system tools!
    I am busy today, but maybe I can have a stab at it tonight. Good luck!
    Message Edited by altenbach on 07-06-2009 08:59 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    langevinFit.png ‏21 KB

  • How to implement non linear navigation Date LOV

    Hi,
    I have a requirement like I need to show non linear combo LOV in my UI which allows the user to navigate to next or previous item in the list.
    Any help on this or do we have any inbuilt design pattern for this component.
    I am using Jdev 11.1.1.7.0.
    Many thanks in advance.
    Regards,
    Dileep.

    Hi Frank,
    Thank you so much for your reply. Sorry, I am not able to attach that component image here.
    Actually it looks like normal combo box LOV, additionally it has two navigation icons both the sides (both left and right hand side) of combo box and allow the user to navigate to previous or next item in the list of values available in the combo box.
    I am not sure whether it is fusion specific custom component or adf component. Any help on this?
    Many thanks in advance.
    Regards,
    Dileep.

  • How to implement moving (linear) averaging in a subVI with dynamic data?

    I was wondering how to implement a moving or rolling linear averaging using a subVI on a set of dynamic data coming from the DAQ Assistant or a counter input channel that will be written using the Write to Measurement File VI?  Below is an example of what I mean.
    Solved!
    Go to Solution.

    You could use the MeanPtbyPt vi to give the running average.  Assuming your code snippet is inside a loop, wire an =0? comparison of the iteration number to the initialize input to reset the value and put 25 (or whatever you want) as the sample length.

  • 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 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

  • Curve fitting only part of a waveform

    I am taking some data from an Oscilloscope and I need to do a curve fit.  As you can see from the data in the attachment the data begins at 0 and ends a 10e-6.  I just want to curve fit the part from 5e-6 to 10e-6.   This is what I have tried
    1) I take the waveform and use a "Get Waveform Components".  I then take the Y data and strip off the first half of the data from the array.  Then I  use a "Build Waveform" and put in the new Y data and the dt data to make the NEW waveform.  I then put it in to the Curve Fitting Express VI.  This works well for the slope, but of course the intercept is off because the data that was at 5e-6 is now at 0.  And the data at 10e-6 is now at 5e-6 since I stripped off the first 5e-6 of data and rebuilt the waveform.   I thought I could use the "t0" value in the "Build Waveform" to set the start of the NEW waveform to be 5e-6, but it seems that the "t0" is only for a timestamp (its a calendar data). 
    2) I thought about converting the waveform in to X and Y data because it would be easy to shift the X data by just adding 5e-6 to each value in the X array.  But then it wouldn't input to the Curve Fitting Express VI. 
    3) I thought about using the "Locations" input to the Curve Fitting Express VI, but I haven't really been able to get that to work. 
    Thanks for any help. 
    Solved!
    Go to Solution.
    Attachments:
    graph.jpg ‏128 KB

    Hello,
    Check out these examples and online docs relating to curve fitting. Perhaps they will be of some use.
     5th-order Curve Fitting Using Curve Fitting Express VI
    Linear Curve Fitting a Random Waveform Graph
    Overview of Curve Fitting Models and Methods in LabVIEW
    Introduction to Curve Fitting
    Best,
    National Instruments
    Applications Engineer

  • Is it possible to simulate large-scal​e non-linear systems using the Simulation Toolkit?

    Hi,
    I am new to LabVIEW, having used Matlab/simulink for a few years. I am trying to simulate a relatively complex non-linear vehicle model. In Matlab/Simulink I would use an m-file to describe the system equations (i.e. x1_dot=..., x2_dot=..., etc.). Is there a similar method in LabVIEW? I have got a simple simulation running using the 'eval formula node', a very ungainly method of substituting variables, and an integrator in a 'simulation node'. It takes about an hour to run a simulation that takes 3 seconds in Matlab. I just need to know if it is realistic to do large-scale simulations in LabVIEW, or if it was not designed for that and I should persuede the management to go
    back to Matlab!!!
    If it is possible, where can I find help on the subject? I have spent a long time looking on the web and come up with very little.
    Many thanks in advance,
    Paul.

    If these are simple differential equations, easiest would be a for loop with a bunch of shift registers, one for each x1, x2, etc. containing the current values.
    In your case, you would calculate all the derivatives from the instantaneous values inside the loop, then add them to each value before feeding them to their respective shift register again.
    The attached very simple example shows how to generate an exponential decay function using the formula dx/dt= kx (and k is negative). The shift register in initialized with the starting condition x=1.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    DiffEQ.vi ‏33 KB

  • Implementation of linear fit between two cursors

    Hi,
    I am trying to implement a linear fit between two cursors, as I am using total of 4 cursors. I would like to implement linear fit between cursor 2&3. Please help me how to implement it and to find a slope. I am also attaching my code.
    With Regards
    Phani kiran
    Solved!
    Go to Solution.
    Attachments:
    Linear Fit Implementaion.PNG ‏44 KB

    phanikiran wrote:
    Hi koen,
    Now I would like to merge both graphs i.e., Bestfit and XY Graph (in the block diagram). Can you suggest me, I have tried with build array and concenate Inputs function, but no use. Dont mine as I  am new to Labview. Thanks in advance.
    First, get rid of the Express XYGraph subVIs and use the "real" XY graph VIs. The Express ones get you going faster for simple things, but your options are limited.
    Take your X and Y arrays for both your original points and the best fit points (just two points, right?) and combine them into clusters of arrays (instead of feeding them into the XY graph). Then combine these into an array and feed it into your graph. It's all outlined in the XY Graph section of the LabVIEW help file.
    The LV Help File is your friend, learn to use it. It gets lonely if you don't look in on it once in a while.
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ

  • Confidence bounds for non-linear fit

    Is it possible to get the confidence bounds for the fitted coeficients when using non-linear fits?

    Hello Dahl
    Do you mean like Upper Bound and Lower Bound output terminals of NI_Gmath.lvlib::Nonlineat Curve fir intervals.vi?
    Message Edited by Eirikur on 01-09-2008 01:25 PM
    Regards,
    Eirikur Runarsson
    Platinum Applications Engineer
    NI Denmark

  • Fit non lineare basato su una funzione f(x)

    -Sto cercando di fare un fit non lineare su una curva. La funzione che utilizzo per il fit è il prodotto di una lorentziana per un polinomio del terzo ordine x un totale di 7 parametri (3 x la lorentziana e 4 x il polinomio).
    Il problema è che il fit non mi soddifsfa affatto. Sarebbe forse utile dare ai parametri un range limitato di valori (almeno x l'ampiezza della lorentziana) entro il quale variare ma non saprei proprio come fare(..e se si possa fare..)
    -Esiste un altro modo x risolvere il problema?
    -E se il numero di parametri salisse a 13 (3 lorentziane e un polinomio del terzo ordine) il calcolo del fit sarebbe ancora più difficoltoso?
    -Vorrei inoltre sapere, una volta assegnati i parametri iniziali, come il blocco proceda nelle iterazioni e cioè se continui ad incrementare il valore dei parametri fino a trovare l'ottimo o se si muova in un range che abbia come centro il valore iniziale dei parametri.
    Grazie

    Ciao Fortu,
    in questo documento puoi trovare informazioni riguardanti l'algoritmo utilizzato per determinare i coefficienti (a1, a2, ..., aM): What is the Difference Between the Two Levenberg-Marquardt VIs in LabVIEW? http://digital.ni.com/public.nsf/websearch/BACF6FDF1B40993686256CC300657BA4?OpenDocument
    Non è possibile, settare un intervallo di appartenza dei coefficienti ma si deve settare solo un valore iniziale. La precisione e la velocità del processo di fitting è fortemente determinato dalla scelta di questi valori iniziali.
    ciao buon lavoro.

  • How can I apply curve fitting to simple BER measurement data?

    I am collecting simple BER data from a communications receiver for modulations such as PSK, CPM, etc. The data looks good but has the usual measurement noise, which I would like to spiffy-up for customer presentations.
    I have tried virtually all of the vi's in the LV Fitting palette, with little or no success. One of the NI AE's provided me with a GP Fit approach, but it has problems when you introduce error. I have attached a vi which demonstrates this, and also shows an attempt on my part to use the Least squares vi, with various functional estimates of the erfc vi. The vi also includes sample data.
    I see MatLab (and possibly Wolfram) has a function specifically for BER smoothing, but NI doesn't, as best I can tell. I feel certain that one or more of the LV fitting vi's can be coerced into working with the correct parameters - but so far I can't find them!
    Has anyone tackled this problem with good results?
    One other thing - has anyone else noticed that the formula used by the LV erfc (complementary error function) is *not* the standard model used for BER/radio communications applications?
    Appendix B of Digital Communications by B. Sklar gives the conversion:
    Q(x) = 1/2 erfc (x/sqrt(2)), where erfc (x) is the LabView vi block.
    Thanks,
    Mark

    Hi Eric,
    Well, BER is just data measured at certain input levels to a receiver. For digital communications systems, we typically use Eb/No to specify the input signal strength, and measure the BER at that level. This is analagous to signal-to-noise ratio (SNR) measurements in the analog domain.
    The BER values tend to run from between .01 and 10E-5, or even 10E-9 for high performance systems. As a result of the wide range of BER values, it is usually plotted on a logarithmic (y-axis) scale. Values of Eb/No are in the range of a few dB, up to perhaps 15~20 dB. So the x-axis is normally 'linear', although in dB.
    I have attached the vi's again, and if you run the LS BER fit vi, you will see the data plotted. If you turn off the noise, you can see a very nice plot - the curve fit vi works fine. But if you add noise (which simulates what you would measure in a real system), and run it several times, you will see all kinds of responses - depending on the noise parameters. What I am looking for is something that gives me a nice smooth graph even with the noise turned on (which is what my real data looks like).
    Thank you,
    Mark

  • 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

  • How to create curve fitted line chart?

    Line chart is formed with straight lines, but how to create curve fitted line chart?

    Jasper wrote a blog on curve fitting charts

  • 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

Maybe you are looking for

  • Best way to connect iMac to TV

    What's the best way to connect my iMac (2011) to my TV? My TV has HDMI inputs and my iMac has Thunderbolt ports, so I know I can connect them with a cable, but they are about 20 feet apart and I think that's too long for a cable run. Does anyone have

  • Partner profile generation

    Hi,   while generating the partner profile it is askimg for partner no but i don't have any partner system is there any option to configure the same system as seneder and receiver , if it is possible tell me the procedure how can we do that. Thanks i

  • Classpath & packages

    I've been struggling to set up my package structure properly. Here's the situation: C:\project\impl2 :contains the files in "package impl2" C:\project\impl :contains classes that import impl2.* (let's call these the "child classes") (OS is Win2000) W

  • Page Question

    Changing the size of a webpage You can change the height and width of a webpage by changing the dimensions of its content area (the main region of a webpage). To change the size of a webpage's content area: If the Page Inspector isn't open, click Ins

  • Creating so file in Unix

    Hi All can someone tell me how to create .so file in unix for JNI JNI needs .so file . i have my program in C i want to create . so file for it. how to do it? Lakshmi