Solving equation with symbolic vector variable
18 ビュー (過去 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]
...
0 件のコメント
採用された回答
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
2 件のコメント
Walter Roberson
2021 年 4 月 19 日
a = [1 2 3 4];
x = sym('x', [1 4]);
eqn = a + 4.*x == x;
temp = struct2cell(vpasolve(eqn, x));
vertcat(temp{:})
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Symbolic Variables, Expressions, Functions, and Preferences についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!