Solving a system of linear equations getting the matrix

조회 수: 1 (최근 30일)
mortain Antonio
mortain Antonio 2011년 5월 13일
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

채택된 답변

Andrew Newell
Andrew Newell 2011년 5월 13일
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
mortain Antonio
mortain Antonio 2011년 5월 14일
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 2011년 5월 14일
I made some changes to the original system I put at the beginnning, but the sapproach is the same....

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by