Clear Filters
Clear Filters

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

1 view (last 30 days)
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?

Accepted Answer

Torsten
Torsten on 30 Aug 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

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!