# Extract solution from struct

36 vues (au cours des 30 derniers jours)
Ali Awada le 6 Déc 2020
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
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

Asvin Kumar le 9 Fév 2021
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
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Structures dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by