Solving a system of linear equations getting the matrix

1 visualización (últimos 30 días)
Hello,
I have a system of linear equation of this shape {Z}=[A_1]{X}+[A_2]{Y}, where Y has different variables (in the example there are 2, but might arrive at 6 in the future) and they are polynomials of grade n=6 (in the example I limit to 2).
example:
z_1=A_0+A_1*x_1+A_2*x_1^2+A_3*y_1+A_4*y_1^2
z_2=A_0+A_1*x_2+A_2*x_2^2+A_3*y_2+A_4*y_2^2
z_3=A_0+A_1*x_3+A_2*x_3^2+A_3*y_3+A_4*y_3^2
z_4=A_0+A_1*x_4+A_2*x_4^2+A_3*y_4+A_4*y_4^2
z_5=A_0+A_1*x_5+A_2*x_5^2+A_3*y_5+A_4*y_5^2
I put the combination of polynomials together. I want to calculate the coefficients A_i, since I know x_i, y_i and z_i.
Is there a function or a straightforward manner to calculate or do you have any suggestion how to approach it?
Thank you Antonio

Respuesta aceptada

Andrew Newell
Andrew Newell el 13 de Mayo de 2011
I'll give you a hint: if you have a problem that can be formulated A*x = b, where A is a matrix and x,b are vectors, then you can solve for x using
x = A\b
EDIT: O. k., next hint: Ignore my symbol names, focus on which are vectors, e.g., x = [A_0; A_1; A_2; A_3; A_4].
EDIT 2: Here is how you do it:
b = [z_1; z_2; z_3; z_4; z_5]; % or b = [z_1 z_2 z_3 z_4 z_5]';
vx = [x_1; x_2; x_3; x_4; x_5];
vy = [y_1; y_2; y_3; y_4; y_5];
A = [ones(size(vx)) vx vx.^2 vy vy.^2];
x = A\b;
A_0 = x(1); A_1=x(2); %etc.
I strongly recommend that you work through some of the introductory material, for example Matrices and Arrays. MATLAB was originally built to handle stuff like this, and it is designed to make it easy.
  3 comentarios
mortain Antonio
mortain Antonio el 14 de Mayo de 2011
So you suggest to define x as the matrix of coefficients and actually the coefficients A_i as the unkown. Is there any function which solves it, like I saw linsolve, I'll try to use it, but this means that I have to define Y, and the x_i to a matrix. Is it what you mean?
mortain Antonio
mortain Antonio el 14 de Mayo de 2011
I made some changes to the original system I put at the beginnning, but the sapproach is the same....

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by