how can I fit nonlinear regression equations with a set of data

2 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2020-2-5
编辑:Star Strider 2020-2-5
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.

更多回答(2 个)

Mohanned Al Gharawi
@ Star Strider
Sorry for that, I just updated the data set.
Thanks

Mohanned Al Gharawi
Thank you so much I appreciate your help.

类别

Help CenterFile Exchange 中查找有关 Linear Regression 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by