# Solving equation with symbolic vector variable

9 views (last 30 days)
Delia Bosshart on 19 Apr 2021
Commented: Delia Bosshart on 19 Apr 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]
...

Stephan on 19 Apr 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 CommentsShowHide 1 older comment
Delia Bosshart on 19 Apr 2021
Thank you!

### Categories

Find more on Conversion Between Symbolic and Numeric in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by