Non linear fitting with 3 independent variables
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (1)
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 Commenti
Shubham
il 8 Mag 2024
Torsten
il 8 Mag 2024
I don't know. It's impossible for me to foresee the pattern of K given a functional relation of 3 independent variables.
Shubham
il 8 Mag 2024
Torsten
il 8 Mag 2024
Is there a way to accept both answers?
No, but no problem - we don't earn our money here :-)
Matt J
il 8 Mag 2024
Is there a way to accept both answers?
You can upvote Torsten's answer (as I now have). With two upvotes, he will receive 4 rep points, the same as he would earn if his Answer was accepted.
Sam Chak
il 8 Mag 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
il 10 Mag 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.
Categorie
Scopri di più su Linear Algebra in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


