Solving equation with symbolic vector variable
53 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Delia Bosshart
le 19 Avr 2021
Commenté : Delia Bosshart
le 19 Avr 2021
I want to solve an equation, a b c d are known vectors and x is the symbolic vector variable I want to solve for.
In the output I get only the 'names' of the elements (x1, x2, ...) How do I get the values of x1,x2 ? Any help is much appreciated.
SIMPLIFIED PROBLEM:
input:
a = [1 2 3 4];
x = sym('x', [1 4]);
eqn = a + 4.*x == x;
vpasolve(eqn, x)
Output:
ans =
struct with fields:
x1: [1×1 sym]
x2: [1×1 sym]
x3: [1×1 sym]
x4: [1×1 sym]
REAL PROBLEM:
Input:
a = data{23:29,6}; %q_inc
b = data{23:29,16}; %q_losses
c = data{23:29,15}; %rho_char
d = data{23:29,14}; %betta_char
x = sym('x', [1 9]);
eqn = (a - b + 6.96.*x + (6-(31.*c)./1000).*x./60*1000 + 31.*c./1000.*d./60*1000)*0.0081 - 0.1824 - x == 0;
vpasolve(eqn,x)
Output:
ans =
struct with fields:
x1: [1×1 sym]
x2: [1×1 sym]
x3: [1×1 sym]
x4: [1×1 sym]
...
0 commentaires
Réponse acceptée
Stephan
le 19 Avr 2021
use the dot-notation
a = [1 2 3 4];
x = sym('x', [1 4]);
eqn = a + 4.*x == x;
sol_x = vpasolve(eqn, x)
sol_x.x1
sol_x.x2
sol_x.x3
sol_x.x4
2 commentaires
Walter Roberson
le 19 Avr 2021
a = [1 2 3 4];
x = sym('x', [1 4]);
eqn = a + 4.*x == x;
temp = struct2cell(vpasolve(eqn, x));
vertcat(temp{:})
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Symbolic Variables, Expressions, Functions, and Preferences 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!