How can I fit this data?
Afficher commentaires plus anciens
Hi everyone,
I am struggling with the following problem:
I have a dataset (Map3D.mat file is included) for which I am trying to fit a function where I have 3 variables and one value for a combination of these 3 variables.
The variables are engine power, altitude and speed. The value is the fuel consumption of the engine. I want to fit this fuel consumption data with a function in such a way that engine power, altitude and speed are input variables and fuel consumption is the output variable. Is this possible? I have been trying stuff with fitnlm but I cannot get it working. I dont get how I can change my data structure to the required format. The Map3D.mat file is structured as follows: 7x21x4 (speed x power x altitude). With a speedvector from as Speed = 0:10:60, a powervector as Power = 5:10:205 and an altitudevector as Altitude = [0 300 600 700].
Currently I found a workaround with the interp3 function which works okay, however it increases the computation time of my code significantly compared to a function evaluation because it gets called often as it is within an iteration loop. I also expect my code to converge faster with a function which fits the desribed dataset.
I am really looking forward to see what you guys think!
Toon
3 commentaires
Rik
le 24 Fév 2020
What sort of function do you expect? If you can write something like the function below, you can use the fitting tools to fit the function parameters.
function val=MyFun(b,x,y,z)
val=x*b(1)+y.^b(2)-sin(z/b(3));%just a random example with the correct syntax
end
Toon
le 24 Fév 2020
darova
le 24 Fév 2020
What about griddedInterpolant / scatteredInterpolant? It creates function only once
Réponse acceptée
Plus de réponses (1)
Alex Sha
le 25 Fév 2020
Hi, toon, how about the model function below:
z = (p1+p2*x+p3*x^2+p4*y+p5*y^2)/(1+p6*x+p7*x^2+p8*x^3+p9*y+p10*y^2);
where x: speedvector, y:Power
Root of Mean Square Error (RMSE): 0.00691844326129822
Sum of Squared Residual: 0.007036134002491
Correlation Coef. (R): 0.998274976728469
R-Square: 0.996552929162226
Adjusted R-Square: 0.996480612990804
Determination Coef. (DC): 0.996552929142504
Chi-Square: 0.0077055307148613
F-Statistic: 4400.72826907425
Parameter Best Estimate
---------- -------------
p1 0.819461830220929
p2 -0.00987471483675952
p3 0.000133551058989172
p4 0.103028178545445
p5 0.00153694829659665
p6 0.00317128381400631
p7 9.70005191197044E-5
p8 3.74684931649973E-6
p9 0.0777991586491392
p10 0.00764599134548915


1 commentaire
Toon
le 25 Fév 2020
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!