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

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Torsten
Torsten il 30 Ago 2022
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

Più risposte (0)

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by