What do I do next to solve for m?

1 次查看(过去 30 天)
clear
syms f m g L I
E = 2*pi*f == sqrt((m*g*L)/I)
E = 
%What is the mass when...
m = solve(E,m)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
m = 
subs(E, f ,0.1);
subs(E, I, 50);
subs(E, g, 9.8);
subs(E, L, 0.5);
Now I need to find a value for m but I'm not sure how to move forward with it

回答(1 个)

Star Strider
Star Strider 2021-10-23
The conditions only apply if the values of the constants are not defined first.
Try this —
syms f m g L I
f = sym(0.1);
I = sym(50);
g= sym(9.81);
L = sym(0.5);
E = 2*pi*f == sqrt((m*g*L)/I);
m = solve(E,m)
m = 
m_vpa = vpa(m, 42)
m_vpa = 
4.02430352745743470696615331289547446903719
.
  2 个评论
Amy Joyce Valencia
Amy Joyce Valencia 2021-10-23
Do I have to use syms for every valuable? Or is there a way to shorten it?
Star Strider
Star Strider 2021-10-23
It’s not necessary to use the Symbolic Math Toolbox at all —
f = 0.1;
I = 50;
g = 9.81;
L = 0.5;
E = @(m) 2*pi*f - sqrt((m*g*L)/I) % Anonymous Function
E = function_handle with value:
@(m)2*pi*f-sqrt((m*g*L)/I)
m = fzero(E, 10)
m = 4.0243
Although it only shows four decimal places, it retains full internal precison, so nothing is lost.
.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by