Extract solution from struct

Hello,
I have the following code to solve a system in an abstract form. The solution is stored in a struct. Can someone help me extract the array(c1, c2, and c3 as a function ot the other terms):
syms h1 h2 mu1 mu2 c1 c3 c4 V
[M]=[(h1+h2)*c3+c4; c3*h1+c4;mu1*mu2*c3]
[L]=[V;c1*h1;mu2*c3]
solution=[L]-[M]
Thanks

Réponses (1)

Asvin Kumar
Asvin Kumar le 9 Fév 2021

0 votes

The setup looks good. You can use the solve function to find the solutions to a given symbolic equation as shown in this example. Here's some sample code:
s = solve(solution==0, [c1 c3 c4]) % substitute 0 for values you have stored in a struct
% same as
% s = solve(solution, [c1 c3 c4])
s =
struct with fields:
c1: [1×1 sym]
c3: [1×1 sym]
c4: [1×1 sym]
s.c1
s.c2
s.c3
ans =
V/h1
ans =
0
ans =
V

Catégories

En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by