optimally selecting elements in matrix to satisfy the system of equations
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi I am sarath, I am working on system of equations that have unknown matrices, which needs to be solved using optimization.
I have 3 different equations which are function of matrices (A,B,C)
A=[0 1 0 0; 0 0 1 0; 0 0 0 1; -a1 -a2 -a3 -a4]
B=[b1;b2;b3;b4]
C=[c1 c2 c3 c4]
I know the right hand side scalar values of all the three equations. I need to solve for this A, B, C matrices such that, those matrices should satisfy the right hand side scalar values.
Requesting for suggestions.
2 comentarios
Amal George M
el 2 de Ag. de 2018
Editada: Amal George M
el 2 de Ag. de 2018
Hi Sarath,
Can you provide details on how these matrices are related or the equation which needs solving?
Respuestas (1)
Aquatris
el 3 de Ag. de 2018
Editada: Aquatris
el 3 de Ag. de 2018
First of all, in Matlab you need to use expm() function for matrix exponentials.
Secondly, your 1st equation is wrong. the right hand side gives 4x1 row vector instead of scalar.
Other than that you can create a function like (i commented out 1st equation since it has errors, but you can look into what the error is in your equation derivation and fix it);
function err = deltah(x)
a1 =x(1);
a2 =x(2);
a3 =x(3);
a4 =x(4);
b1 =x(5);
b2 =x(6);
b3 =x(7);
b4 =x(8);
c1 =x(9);
c2 =x(10);
c3 =x(11);
c4=x(12);
A=[0 1 0 0; 0 0 1 0; 0 0 0 1; -a1 -a2 -a3 -a4];
B=[b1;b2;b3;b4];
C=[c1 c2 c3 c4];
I = eye(4);
% eq(1) = 2.12-C*(expm(0.9*A)*(expm(0.1*A)*(inv(I-expm(4.14*A)*(inv(A)* ...
% ((expm(4.14*A)-2*expm(4.04*A)+2*expm(1.97*A)-I)*B))))+inv(A)*(expm(0.1*A)-I)*1*B)- ...
% (inv(A)*(expm(0.9*A)-I)*B));
eq(2) = -0.1-C*(inv(A)*(inv(I-expm(4.14*A))*(expm(4.14*A)*(I-expm(0.1*A)))- ...
(expm(0.1*A)-I))*1*B);
eq(3) = 0.1-C*(inv(A)*(inv(I-expm(4.14*A))*(expm(4.24*A)-2*expm(4.14*A)+2*expm(2.07*A)- ...
expm(0.1*A))+(expm(0.1*A)-I))*1*B);
err = norm(eq);
end
Than, in the command window, you can use fminunc or any other optimization functions to have the solution and assign them to the correct variables;
x = fminunc(@deltah,rand(12,1));
a1 =x(1);
a2 =x(2);
a3 =x(3);
a4 =x(4);
b1 =x(5);
b2 =x(6);
b3 =x(7);
b4 =x(8);
c1 =x(9);
c2 =x(10);
c3 =x(11);
c4=x(12);
With the 1st equation omitted, the value of x I got is;
x =
0.3449
-0.0326
0.3539
1.0273
0.2967
0.7542
-0.5809
-0.4496
-1.0049
0.2925
-0.9052
0.8451
and using these, the values of right hand side of the 2nd equation was exactly -0.1000 and the 3rd equation was exactly 0.1000.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!