How can I specify a parameter to solve a system of equations symbolically?

조회 수: 1 (최근 30일)
I have defined a variable for time (t), velocity (v) and postion (p):
syms v_0 t_1 v_1 p_1
Now a define a system of equations to calculate the position and speed at time t_1 depending on the initial speed v_0:
eqns_1 = [ ...
t_1 == 1.0, ...
v_1 == v_0, ...
p_1 == v_0 * t_1, ...
]
As a result I would expect:
struct with fields:
t_1: 2
v_1: v_0
p_1: 2*v_0
I tried
solution_1 = solve(eqns_1)
and
solution_2 = solve(eqns_1,'ReturnConditions',true)
which both deliver
struct with fields:
t_1: 1
v_0: p_1
v_1: p_1
So how can I specify that v_0 is my parameter and not p_1?

채택된 답변

Torsten
Torsten 2022년 8월 30일
syms v_0 t_1 v_1 p_1
eqns_1 = [ ...
t_1 == 2.0, ...
v_1 == v_0, ...
p_1 == v_0 * t_1, ...
];
solve(eqns_1,[t_1,v_1,p_1])
ans = struct with fields:
t_1: 2 v_1: v_0 p_1: 2*v_0

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by