Generating Multivariate Polynomial Coeffients with known Constants

8 visualizaciones (últimos 30 días)
I am extremely new to MatLab and am having a hard time trying to generate Coefficients from this equation:
t= (A * a) + (B * s) + (C * s * a)+ (D * s^2) + (E * s^2 * a) + (F)
I have the data for t,s,a.
Trying to find (A,B,C,D,E,F)
I can remove the Coefficient (F) if need be, being it is just an offset, and I have (t).
I could post what I have tried, but I usually dont save it because I am not getting close.
I do have Curve Fitting, Statistics, and Optimization Toolboxes thinking it would help.
I have also tried polyfit and polyfitn.
Also, if this has been answered a hundred times, what would best describe that equation for searching?

Respuesta aceptada

Steven Lord
Steven Lord el 2 de Jul. de 2024
See the Multiple Regression section on this documentation page for an example you can adapt to your equation. Make sure you use array operators when constructing the columns of the design matrix.
  7 comentarios
Steven Lord
Steven Lord el 3 de Jul. de 2024
If you use more information (and so more equations) that will also affect the solution. To use Cleve's example, if I told you that the two numbers have an average of 3 there are multiple solutions (3 and 3, 4 and 2, 6 and 0, etc.)
A = [1/2 1/2; 1 -1];
b = [3; 2];
solutionsToFirstEquation = [3 4 6 16-pi; 3 2 0 -10+pi]
solutionsToFirstEquation = 2x4
3.0000 4.0000 6.0000 12.8584 3.0000 2.0000 0 -6.8584
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
checkFirstEquation = A(1, :)*solutionsToFirstEquation
checkFirstEquation = 1x4
3 3 3 3
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
If I then add the additional information that the difference of the two numbers is 2 the solution is unique. The solution is the second column of solutionsToFirstEquation.
x = A\b
x = 2x1
4 2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
satisfiesBothEquations = A*solutionsToFirstEquation % Only 2nd is right
satisfiesBothEquations = 2x4
3.0000 3.0000 3.0000 3.0000 0 2.0000 6.0000 19.7168
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
satisfiesBothEquations2 = [A*x, b]
satisfiesBothEquations2 = 2x2
3 3 2 2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Eric
Eric el 4 de Jul. de 2024
I can't tell if constraints on the coefficients would help me or not.
I understand (now) that if I am looking for a specific outcome, then I need to apply specific cirtieria for the output to meet.
I can't seem to find how to apply constraints to the coefficient data as it is calculated. Also, I would assume this would be linear constraints:
A= >= -16 & <= 16
B= >= -64 & <= 64
C= >= -.25 & <= .25
D= >= -2.000 & <=1 .999
E= >= -.0078 & <= .0078
F= >= -2048 & <= 2048

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Least Squares en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by