How to solve equation with several unknown variables for a specific variable?
2 ビュー (過去 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!
0 件のコメント
採用された回答
Star Strider
2023 年 12 月 9 日
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
eqn2 = isolate(eqn,cos(a))
Sa = rhs(eqn2)
Sa = simplify(Sa, 500)
.
2 件のコメント
その他の回答 (1 件)
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))
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




