polyfit with multiple dependent variables
70 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
alpedhuez
am 17 Dez. 2020
Kommentiert: alpedhuez
am 17 Dez. 2020
I think
can handle multiple dependent variables. But when I tried
Fit = polyfit([x1 x2], x3, 1);
I got an error message
Error using polyfit (line 44)
The first two inputs must have the same number of elements.
Although I checked x1, x2, x3 has the same length. What can one do?
0 Kommentare
Akzeptierte Antwort
Bjorn Gustavsson
am 17 Dez. 2020
The polyfit function only works for 1-D polynomials, as far as I understand things. However there is an n-dimensional polynomial-fitting function package on the file exchange: polyfitn. That should give you the tools necessary to solve this problem. I've used it without much problems and to sensible success.
HTH
Weitere Antworten (1)
Remy Lassalle-Balier
am 17 Dez. 2020
I think polyfit does not suport multiple dependent variables. The documentation is quite clear about the fact the first parameter should be a vector and not a matrix.
You can still run your fit manually:
X = [ ones( numel( x1 ) , 1 ) , x1(:) , x2(:) ];
fitParam = X\x3(:);
Fittedx3 = X * fitParam;
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!