how can I fit nonlinear regression equations with a set of data
조회 수: 1 (최근 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
댓글 수: 0
채택된 답변
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.
댓글 수: 0
추가 답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fit Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!