Robert
Robert

Reputation: 381

How to solve matrix equation in matlab?

I have H and G and Am matrix. All are 4x4. Both H and G are symmetrical and next equation: HAm+AmH=-G. How can I solve this in matlab? Am I right about this: 2HAm=-G and 2AmH=-G?

But when I use H=linsolve(Am,-G/2) gives me nonsymmetrical matrix

H=linsolve(Am,-G/2)

Upvotes: 0

Views: 803

Answers (2)

Trickk
Trickk

Reputation: 93

Here is a similar problem . You can see

Find the all elements of unknown matrix in MATLAB?

You can use equationToMatrix in matlab to solve a set of equations.

Upvotes: 2

Hadi
Hadi

Reputation: 1213

use syms if variable Y is not known

for example:

 syms y
 solve(2*y-4==0)

 ans= 2

to specify the matrix eq you should define the size of y:

 y=sym('y',[2,1]);
 A=[1 0;0 1];
 c=[1;2];
 z=[0;0];
 B=solve(A*y-c==z);

B is a structure which stores value of y1 and y2

 B.y1
 ans= 
      1

for this question:

H=sym('H',[4,4]);
B=solve(H*Am+Am*H==G)
B.H11 % to retrieve H11

Upvotes: 0

Related Questions