Multi Variable Non-linear Curve Fitting in MATLAB
117 ビュー (過去 30 日間)
古いコメントを表示
Dear all,
I am trying to curve fit my objective variable "tau" which is called Ignition delay (unit, milli-sec). tau is modeled as a function of three variables as listed below
- Temperature, T (K),
- Pressure, P (atm), and
- Equivalence ration, phi (unitless)
The proposed curve-fitting equation has the following form. Here, a, b, c, d, e are the curve-fitting constant. And, here i = 3. Therefore, in total there is 15 curve-fitting constants.
tau(i) = ai * (p^bi) * (T^ci) * EXP(di / T) * (phi^ei)
Can anyone please suggest which MATLAB curve-fitting/regression tool should I use? Thanks in advance. I have attached a test data file if anyone is interested. Thanks.
****
Ultimate expression for the tau (if anyone is interested why i is set to be 3)
tau = (tau-1 + tau-2 + tau-3) / { (tau-1+tau-2) * tau-3 }
0 件のコメント
採用された回答
Star Strider
2019 年 2 月 11 日
I would do this:
[D,S] = xlsread('Data_Source.xlsx');
EPT = D(:,1:3);
tauv = D(:,4);
% tau(i) = ai * (p^bi) * (T^ci) * EXP(di / T) * (phi^ei)
taufcn = @(b,x) b(1) * x(:,2).^b(2) .* x(:,3).^b(3) .* exp(b(4)./x(:,3)) .* x(:,1).^b(5);
[B,R,J,CovB] = nlinfit(EPT,tauv,taufcn,rand(5,1));
BCI = nlparci(B,R,'covar',CovB);
You can have a matrix independent variable in all curve-fitting and optimization applications in MATLAB. You simply have to refer to the individual columns of the matrix as the different independent variables. (Here, they are ‘EPT’=[‘Equivalence Ratio’, ‘Pressure’, ‘Temperature’]), so ‘x(:,1)’ is ‘Equiv. Ratio’, and so for the others), with ‘tau’ as the single dependent variable.
I also calculate the parameter confidence intervals in this code, finding that ‘b(1)’ is not significantly different from zero, and so is not needed in the model. The others are all significant.
Experiment to get the result you want.
3 件のコメント
Miraboreasu
2022 年 11 月 27 日
@Star Strider Hello, sorry to bother you, I am using nlinfit, I have 2 variable, so I cannot plot 2D to see if the fitting is fine, so should I sum up the R? or how to evaluate the my fitting?
その他の回答 (3 件)
Stephan
2019 年 2 月 11 日
編集済み: Stephan
2019 年 2 月 11 日
Hi,
i suggest to model this as a system of 4 equations with the 15 unknownse and use . 3 equations to calculate the tau(i) values and the 4th equation to calculate tau from the results of equations 1-3. Then subtract the measured value for tau from the result of equation 4. This is a job for fsolve.
Best regards
Stephan
Alex Sha
2019 年 8 月 3 日
Root of Mean Square Error (RMSE): 1.09231944926872
Sum of Squared Residual: 1355.43178122881
Correlation Coef. (R): 0.999883881381431
R-Square: 0.999767776246396
Adjusted R-Square: 0.999766954942228
Determination Coef. (DC): 0.999758349281268
Chi-Square: 190.539760828559
F-Statistic: 331766.054300988
Parameter Best Estimate
---------- -------------
a1 0.509520813430713
b1 -0.410333298909599
c1 -1.88156624504009
d1 11326.3070797332
e1 -0.0582321791543802
a2 3.53682438415215E-6
b2 0.378224086620891
c2 -2.32994413523028
d2 19151.2160516163
e2 -0.0238944122916122
a3 2.16069394348543
b3 -0.87187579659814
c3 -0.258436168897444
d3 3550.15220868462
e3 -2.03331105345266
3 件のコメント
S0852306
2023 年 7 月 23 日
Try this: Multivariable surface fitting
The fitted surface matches your data quite well:
root mean square error : 0.1482
sum of square error : 24.9477
mean absolute error : 0.0971
clear; clc; close all;
T=readtable("Data_Source.xlsx");
%%
data(1,:)=T.Equiv_Ratio_Phi';
data(2,:)=T.Pressure_P_atm_';
data(3,:)=T.Temperature_T_K_';
label=T.IDT_Tau_milli_sec_';
%%
NN.InputAutoScaling='on'; NN.LabelAutoScaling='on';
InSize=3; OutSize=1;
LayerStruct=[InSize,10,10,10,OutSize];
NN=Initialization(LayerStruct,NN);
%%
option.MaxIteration=1500;
NN=OptimizationSolver(data,label,NN,option);
Stats
R=FittingReport(data,label,NN);
%%
figure
p=NN.Evaluate(data); % use this function to evaluate fitted model
plot(label,'.')
hold on
plot(p)
legend('target value','fitted n-d surface')
% SSE=sum(R.ErrorVector.^2); % MSE=mean(R.ErrorVector.^2); % RMSE=sqrt(MSE)
The model I used is a neural net, it's a universal approximator (able to approximate any continuous function given
enough parameters), although it has a fancy name, its mathematical model is actually quite simple.
Detail math info can be found at file exchange website.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!