How to solve equation with several unknown variables for a specific variable?

3 次查看(过去 30 天)
Hello
Im trying to solve an equation using the following code:
syms w0 g l r l a m
eqn = m*g*l*(1-cos(a))==1/2*1/2*m*(r^2+2*l^2)*((r^2/(r^2+2*l^2))*w0)^2
Sa = solve(eqn,cos(a))
However it gives me these answers:
eqn =
logical
0
Warning, solving 2 equations for 1 variables
Sa =
1/2 pi
I know the answer should be:
cos(a)=1-(w0^2/(4*g*l))*(r^4/(r^2+2*l^2))
Is there any way to solve this problem? Any help is greatly appreciated!

采纳的回答

Star Strider
Star Strider 2023-12-9
The isolate function is helpful here —
syms w0 g l r l a m
eqn = m*g*l*(1-cos(a))==1/2*1/2*m*(r^2+2*l^2)*((r^2/(r^2+2*l^2))*w0)^2
eqn = 
eqn2 = isolate(eqn,cos(a))
eqn2 = 
Sa = rhs(eqn2)
Sa = 
Sa = simplify(Sa, 500)
Sa = 
.

更多回答(1 个)

John D'Errico
John D'Errico 2023-12-9
When you pose it as you did to solve, solve assumes you are trying to solve TWO equations, one of which is the equation
cos(a) == 0
READ THE WARNING MESSAGE!
Instead, do this:
syms w0 g l r l a m
eqn = m*g*l*(1-cos(a))==1/2*1/2*m*(r^2+2*l^2)*((r^2/(r^2+2*l^2))*w0)^2;
isolate(eqn,cos(a))
ans = 

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by