LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding two furthest apart points with near constant gradient inbetween

In labview I'm loading in a collection of temperature values, with their corresponding time values.

 

Once labview has done this I was looking to load back in the values and find the two furthest apart values of temperature that maintain a constant gradient inbetween. For example:

 

tempgraph.jpg

for the above set of data, labview would return values t1 and t2. Is this do-able in labview?

 

Any help would be much appreciated as I have no idea where to start with this.

 

Thanks,

Pete

0 Kudos
Message 1 of 7
(3,228 Views)

Pete,

 

Essentially what you want is a largest region where the 2nd derivative of temperature is within some tolerance level of zero. 

 

You could write your own VIs to do the differentiation or use Derivative x(t).vi in the mathematics pallette.  You would use this twice. Then you would need write some logic to find the longest interval of the 2nd derivative that was within some tolerance of zero.  Then you would find the indices of the endpoints of that interval and index your temperature array with those indices to get T1 and T2.

 

J

0 Kudos
Message 2 of 7
(3,217 Views)

Taking the second derivative would probably need some serious filtering. I probably would use Linear Fit Coefficients PtByPt VI using a reasonable sample length and loop over your data. Now check how the slope changes and find the boundaries of the longest flat spot.

 

Can you attach a typical datafile? Is there always exactly one linear segment? Is the midpoint always in a similar location relative to the start?

0 Kudos
Message 3 of 7
(3,208 Views)

Here is a typical datafile graph produced. It is a temperture vs log time graph. So the last data point will always be at the required gradient. So I guess I wish to find the earliest time (and corresponding temperature) at which this (or near this) gradient begins. Is there an easy way to do this? Also, there are some data points that dont fit the general trend of the data, is there anyway to filter these out during the calculations longest gradient?

 

 

Graph.jpg

 

Thanks for your help.

 

Pete

0 Kudos
Message 4 of 7
(3,153 Views)

There must be some expectation about when the data become linear or minimum duration, no?

 

You could do a linear fit for that minimum duration ending with the last data point. You could then test for statistical outliers of the residuals of all the data.  The index of last data point before the residuals begin to fail the outlier test could be used to redefine the duration of the linear evolution of temperature.  You could run one more iteration to find the linear fit and the residuals for all of the data with an outlier test. I guess you would assume that the temperature residue about this line would be normally distributed in the linear portion.

0 Kudos
Message 5 of 7
(3,148 Views)

Well, I meant you should attach some actual data. I cannot try to fit a picture. 😉

 

For better out-lier rejection, you could use the bisquare option of linear fit.

0 Kudos
Message 6 of 7
(3,133 Views)

Datafile attached.

 

Thanks again, I'm looking into your suggestions.

 

Pete

0 Kudos
Message 7 of 7
(3,123 Views)