Solve an equation while we have an if statement that makes the coefficient depends on the variable
1 次查看(过去 30 天)
显示 更早的评论
I want to solve this
M=166700; %kg%;
g=9.81; %m/s2%;
ro=2500; %kg/m3%;
H=6; %m%;
sigmac=20*(10^6); %Pa%
syms d;
if(d<0.8)
F2=3*(10^6)*(d^2)-30644;
M1=5*(10^7)*(d^2)-552844;
else
F2=103867*(d^2)+(10^6);
M1=2*(10^6)*d^2+2*(10^7);
end
F1=17759*(d^2)+1801.8;
m=sigmac-(M*g/(d^2))-2*ro*H*g+(6*H*F1/(2*(d^3)))+(6*H*F2/(d^3))+(M1*6/(d^3));
fsolve(m,d)
I am not getting an answer because the if test cannot be done without a value for d. Value that I aim to find by this code
1 个评论
回答(1 个)
Walter Roberson
2022-5-28
typically the best way to solve these situations is to run both branches separately, vpasolve() each of the branches, test each result to see if it is within the constraints for the branch. There might be several answers.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Equation Solving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!