From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Curve fit with prescribed end conditions

Curve fitting with prescribed end conditions

0 Kudos
Message 1 of 13
(3,286 Views)

Do you have a question?

0 Kudos
Message 2 of 13
(3,279 Views)

Yes I do, what curve fitting procedure should I use.

0 Kudos
Message 3 of 13
(3,254 Views)

Use for what?

 

Please try to give some details with your question.  Perhaps attach a screenshot of what your data looks like.  There are many differrent curve fitting routines, and which one is the right one will depend on the kind of data you are trying to fit.

 

What kind of end conditions are you talking about?  Are they that the curve must go through a specific point, or the slope of the curve at the endpoints must meet a certain value?

0 Kudos
Message 4 of 13
(3,226 Views)

I do curve fitting of experimental data with fixed end conditions, it is with a fixed data value and the first derivative value at one end of the experimental data range. For example measuring time dependent gas outflow from a tank with a jittery transducer. When the tank is empty the pressure level is ambient and constant in time.  The entire data set can be divided into two segmwnts and treated separately.  The second segment, when pressure is constant can be easily fitted with a straight horizontal line in the time domain.  The first segment, when pressure was dropping can be fitted e.g. with a polynom or exponential fit. Now, the curve fitted to the first segment of data when the pressure was dropping in time must end with the initial value and first derivative of the second sement of tha straight line so the overall curve fit is smooth and continuous when the two segments are merged. I am looking for a LabView example to solve this problem. Thanks for any suggestions.

0 Kudos
Message 5 of 13
(3,217 Views)

The function exp(x)-1 flattens out for x -> 0. Fit to that with suitable scaling on x and a possible offset if the final value is not zero. Then you may not need separate segments. It mught be useful to fit a straight line to the ambient data points to get a good estimate for the offset.

 

Lynn

 

0 Kudos
Message 6 of 13
(3,199 Views)

Hi Lynn,

 

thanks for the suggestion.  However, this will work only in the simple case I described to you.  We have situations that we need to fit a conrinuous curve to several segments, and some of the segments might be constantly increasing or decreasing in time (known incline straight lines).  What I have in mind is something similar what used to be in Fortram IMSL libraries, which I used about 25 yeras ago (I do not do fortran any more, I am solely hooked on Labview).  There were subroutines for curve fitting where you could specify one or both end point values and their derivatives.  The subroutines then fitted (based on selected method) the curve through these points and their first derivatives; the connestion with linear segments was then smooth without any unwanted wiggles and oscillations.  This is what I am looking for in Labview, and it seems to me that such a vi is not available.

Please, let me know.

Jan

 

   

0 Kudos
Message 7 of 13
(3,187 Views)

You simply need to define the model as you explained. Seems trivial. Some of the parameters are the points where the slope changes. Other paramters are the slopes for each segment. One parameter would be the starting point (offset). The rest should fall into place.

 

Show us your data and model.

0 Kudos
Message 8 of 13
(3,177 Views)

As Christian mentioned, setting up such a piecewise fit is pretty straightforward.  Attached is an example that uses a piecewise exponential/linear fit.  The model function is commented and shows the derivation of the equations. If the exponential model parameters are given, and the position in the data where the models change is also given, and we assume the curve is smooth and continuous, then the slope and intercept of the line are completely specified. Hopefully this will get you started.

 

-Jim

Message 9 of 13
(3,165 Views)

Hi Jim,

 

thanks for the examples, I hope they will be usefull.  However, I cannot open them, I am still on VERSION 10 and the examples are V14.  Can you reload these example into V10?  I will appteciate your help.

 

Thanks,

Jan

0 Kudos
Message 10 of 13
(3,147 Views)