Solving equation with symbolic vector variable

36 次查看(过去 30 天)
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]
...

采纳的回答

Stephan
Stephan 2021-4-19
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Equation Solving 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by