Non linear fitting with 3 independent variables
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a dataset consisting of one dependent variable (K) and 3 independent variables (a, IL, Vf). I am trying to fit a function which could represent dependent variable with fair amount of accuracy.
I have attached the Data.mat file consisting of the dataset.
The form I am trying to fit is -
K = (A - B*IL - C*a)*(D*exp(-E*Vf))
LaTeX form:
initial guess could be - , , , ,
I want the optimised coefficients for the best fitting. How to do this in curve fitting app I was able to do 2 independent variables. I am not aware of how to do this.
Also if not this function how to find some other simple function/functional forms that could represent this data. In academic research lot of people find correlation like this.
load('Data.mat');
PS - Please don't suggest a polynomial type fit consisting of linear, square and interaction terms. As the aim is to have minimum coefficients ie simpler equation.
2 commentaires
Torsten
le 8 Mai 2024
The D in your fitting function makes the problem overfitted - D must be absorbed in A, B and C.
Réponse acceptée
Matt J
le 8 Mai 2024
Modifié(e) : Matt J
le 8 Mai 2024
S=load('Data');
f=@(E,S)exp(-E.*S.Vf);
funlist={f, @(E,S) -S.IL.*f(E,S), @(E,S) -S.a.*f(E,S)};
[E,ABC]=fminspleas(funlist,2.65, S, S.K); %From File Exchange: https://www.mathworks.com/matlabcentral/fileexchange/10093-fminspleas
[A,B,C,E]=deal(ABC(1), ABC(2), ABC(3),E)
pred=(A - B*S.IL - C*S.a).*exp(-E.*S.Vf);
[pred,is]=sort(pred);
h=plot([S.K(is),pred]); legend 'K Measured' 'K Fit'
[h.Marker]=deal('x','o');
2 commentaires
Plus de réponses (1)
Torsten
le 8 Mai 2024
Modifié(e) : Torsten
le 8 Mai 2024
M = load("Data.mat");
fun = @(A,B,C,E)(A - B*M.IL - C*M.a).*exp(-E*M.Vf);
f = @(A,B,C,E) fun(A,B,C,E) - M.K;
A0 = 13.5*13.2;
B0 = 0.2*13.2;
C0 = 0.002*13.2;
E0 = 2.65;
z0 = [A0,B0,C0,E0];
sol = lsqnonlin(@(z)f(z(1),z(2),z(3),z(4)),z0)
A = sol(1);
B = sol(2);
C = sol(3);
E = sol(4);
n = numel(M.IL);
hold on
plot(1:n,M.K,'ob')
plot(1:n,fun(A,B,C,E),'r')
hold off
7 commentaires
Sam Chak
le 8 Mai 2024
Have you studied the amplitude of K and observed the patterns of IL, a, and Vf, before suggesting the use of an exponential decay function? The coefficients of the heaviside 'IL' and staircase 'a' have a lesser impact on K compared to the sawtooth-like wave 'Vf'.
The output signal K may or may not have the same frequency as the input signal Vf. It depends on the specific system and the nature of the relationship between K and Vf. Additionally, there may be a phase lag between the input Vf and output K signals, which can also vary depending on the system dynamics.
Could you find the peaks (crest and trough) of K and then identify two mathematical models that fit the upper and lower envelopes of K? The fitting model for K should be bounded by the mathematical models of the upper and lower envelopes. In fact, the fitting model can be a parametric function of the two envelopes.
Alex Sha
le 10 Mai 2024
@Shubham Your data looks very unreasonable,taking the first 12 sets of data as an example:
a IL Vf k
150 0 0.3 80.62278276
150 0 0.4 65.35516476
150 0 0.5 53.38355585
150 0 0.55 44.04684674
150 0 0.3 93.39806254
150 0 0.4 72.1188811
150 0 0.5 59.5095425
150 0 0.55 49.09761477
150 0 0.3 106.1160211
150 0 0.4 81.98023891
150 0 0.5 67.42473537
150 0 0.55 55.30916884
It can be seen clearly that the values of all "a" and "IL" are same, however, it is strange that the same "Vf" value corresponds to a completely different "k" value,for example, Vf=0.3, corresponded k are 80.62278276, 93.39806254 and 106.1160211, respectively.
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!