0
|
1330 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
GROUPS:

# How to derive an equation with 2 input parameters for data using FindFit?

Posted 7 months ago
 I have experimentally monitored the FuelGaugeOutput(mV) and Tilt angle(degrees) for a range of known amounts of fuel (the measured level drops as tank is tilted due to placement of probe). The plan is to derive a forumula that, given FuelGaugeOutput & Tilt Angle it can estimate the actual fuel. Each measurement is, given a known level of Fuel & Known Tilt angle, measure Fuel Guage Output. Data is therefore {TiltAngleDegrees, FuelGuageOutput(mV), KnownFuel}. Goal is to derive forula so given a Tilt Angle and FuelGaugeOutput can then derived estimated fuel in tank. E.g. {18.19,540,1} => ~18 degrees tilt on tank, 540 fuel probe reading, 1L of fuel in tank New to Mathematica and not sure how to do this. Can mathematic derive best equation to use, then once this is found find the constants for the formula to use. Data is: {{0.57,535,0},{0.36,901,1},{10.51,757,1},{18.19,540,1},{1.02,1055,2},{6.13,1049,2},{11,938,2},{18.46,849,2},{24.12,659,2},{0.41,1162,3},{5.83,1090,3},{10.77,1089,3},{18.3,1051,3},{25.14,889,3},{0.31,1380,4},{6.32,1307,4},{10.51,1207,4},{18.54,1093,4},{24.34,1057,4},{0.67,1558,5},{5.7,1475,5},{11.13,1409,5},{18.7,1268,5},{25.3,1162,5},{0.67,1680,6},{5.48,1634,6},{10.56,1555,6},{19.02,1462,6},{24.75,1351,6},{0.63,1829,7},{5.49,1771,7},{10.67,1708,7},{18.65,1607,7},{24.52,1523,7},{0.85,1930,8},{5.82,1898,8},{10.55,1842,8},{18.92,1785,8},{24.58,1713,8},{0.45,2064,9},{5.65,2030,9},{10.99,1989,9},{18.1,1918,9},{24.91,1851,9},{0.62,2188,10},{5.9,2129,10},{18.21,2050,10},{24.55,2011,10},{0.5,2270,11},{5.69,2245,11},{10.13,2239,11},{18.55,2174,11},{23.8,2143,11},{0.85,2382,12},{5.45,2366,12},{10.21,2333,12},{18.94,2291,12},{24.61,2249,12},{0.69,2494,13},{5.59,2484,13},{11.28,2463,13},{18.7,2428,13},{24.94,2390,13}}
5 Replies
Sort By:
Posted 7 months ago
 @Henrik - thanks very very much! This tool is quite amazing.Is there a way to get it to display the full formula with parameters replaced with values? I'm noting if I just type Params-Return I can get these. [I keep looking]. Thanks again
Posted 7 months ago
 Ah, yes! You get the formula by typing model /. params (* Out: -2.1819518 + 0.0643615 x - 0.000599989 x^2 + 0.0000333168 x^3 + 0.00281313206 y + 1.25551298*^-6 y^2 *) This expression was used for the plot command.EDIT: I probably should mention that the coefficient of the last term 1.25551298*^-6 means 1.25551298 * 10^(-6).
Posted 7 months ago
 ok got it thanks. If I wanted to make it a little more accurate around the low fuel end, would I effectively be able to do this by say (a) doing a few more measurements around this end [e.g. a few more measurements at different tilt angles in the 1L to 3L area], and (b) maybe drop down the number of points at the higher end [e.g. say do 7/9/11/13L, instead of 7/8/9/10/11/12/13] ?
Posted 7 months ago
 Well, for me hard to tell. Maybe anyone else has more experience with data fitting. More data in combination with a better model would certainly help. And I would repeat some measurements to get an idea about their general accuracy before making an elaborated model.
Posted 7 months ago
 Can mathematic derive best equation to use, ... No, I am afraid, you have to try with some general expression or with some clever assumptions. Here is a first attempt. Let data be your data, then: {{xmin, xmax}, {ymin, ymax}} = Most[MinMax /@ Transpose[data]]; (* assumed simple model: *) model = (a0 + a1 x + a2 x^2 + a3 x^3) + (b0 + b1 y + b2 y^2); (* calculation of the parameters: *) params = FindFit[data, model, {a0, a1, a2, a3, b0, b1, b2}, {x, y}]; (* plot of the data: *) gr = Graphics3D[{PointSize[Large], Point[data]}]; (* plot of the model using the calculated parameters: *) p3D = Plot3D @@ {model /. params, {x, xmin, xmax}, {y, ymin, ymax}}; (* showing both in the same graphic: *) Show[p3D, gr]