Solving equation with symbolic vector variable
조회 수: 53 (최근 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!