I have H and G and Am matrix. All are 4x4. Both H and G are symmetrical and next equation: H Am+Am H=-G. How can I solve this in matlab? Am I right about this: 2H Am=-G and 2Am H=-G?
But when I use H=linsolve(Am,-G/2) gives me nonsymmetrical matrix
H=linsolve(Am,-G/2)
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.