The equation I want to solve is
syms w v;
rho_air = 1.25;
equ = w == 0.5 * rho_air * v^2
The problem is that sometimes, I want to solve w from v, an sometimes from v to w.
How can I do it?
I only know to do it like this(This is now not working, and I don't know why):
syms v;
rho_air = 1.25;
w = 1;
equ = w == 0.5 * rho_air * v^2;
But then I have to change it to solve v, like
syms w;
rho_air = 1.25;
v = 1;
equ = w == 0.5 * rho_air * v^2;
which is quite repetative. Is there anyway to solve it more elegantly?
In old Matlab versions you need to define the equation as a string; then you can apply solve
:
>> syms w v;
rho_air = 1.25;
>> equ = 'w = 0.5 * rho_air * v^2';
>> solve(equ, w)
ans =
0.5*rho_air*v^2
>> solve(equ, v)
ans =
(2^(1/2)*w^(1/2))/rho_air^(1/2)
-(2^(1/2)*w^(1/2))/rho_air^(1/2)