how can I fit nonlinear regression equations with a set of data
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohanned Al Gharawi
am 5 Feb. 2020
Kommentiert: Star Strider
am 5 Feb. 2020
Hello everybody
I’m trying to find a nonlinear relationship between two input variables and one dependent variable (output). I do have a set of data that have three columns, the first two columns are the input variables and the third one is the output value. Any suggestion to figure out that? I have tried to use the regression and classification apps in the Matlab.
The attached file is a part of this data.
Thank you
0 Kommentare
Akzeptierte Antwort
Star Strider
am 5 Feb. 2020
Bearbeitet: Star Strider
am 5 Feb. 2020
There is no relationship. Every value in the third column is uniformly 1:
T = readtable('data1.xlsx','ReadVariableNames',0);
UT3 = unique(T{:,3})
producing:
UT3 =
1
With ‘data2.xlsx’, you can fit anything you want to those data, depending on what they represent and the process that created them.
Two possibilities, both using linear regression:
T = readtable('data2.xlsx','ReadVariableNames',0);
xv = linspace(min(T{:,1}), max(T{:,1}), 20);
yv = linspace(min(T{:,2}), max(T{:,2}), 20);
[Xm,Ym] = ndgrid(xv, yv);
DM1 = [T{:,[1 2]}, ones(size(T{:,1}))];
B1 = DM1 \ T{:,3};
zv1 = [Xm(:), Ym(:), ones(size(Xm(:)))] * B1;
Zm1 = reshape(zv1, size(Xm));
DM2 = [T{:,1}, 1./T{:,2} ones(size(T{:,1}))];
B2 = DM2 \ T{:,3};
zv2 = [Xm(:), 1./Ym(:), ones(size(Xm(:)))] * B2;
Zm2 = reshape(zv2, size(Xm));
figure
stem3(T{:,1}, T{:,2}, T{:,3})
hold on
mesh(Xm, Ym, Zm1)
hold off
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
figure
stem3(T{:,1}, T{:,2}, T{:,3})
hold on
mesh(Xm, Ym, Zm2)
hold off
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
The best fit will be to estimate the relevant parameters of a mathematical model of the process that created them. Beyond that, you can fit anything to them.
0 Kommentare
Weitere Antworten (2)
Siehe auch
Kategorien
Mehr zu Linear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!