Find roots of a function with multiple inputs
이전 댓글 표시
I am trying to use fzero to find roots of an equation. In the function, tw, tf and b are variables with a set value, Mx is a vector where I hope to use a for loop to repeat the fzero function to find roots with different Mx values. I dont know how to input the values or even if this is the right way to approach this problem.
function y=f(d,Mx,tw,tf,b)
y=355/Mx*(d^2*tw/12+tf^3*b/6+tf*b*(d+tf)^2/2)-d/2+tf
답변 (1개)
And you want to solve for d ?
syms d Mx tw tf b
y = sym('355')/Mx*(d^2*tw/sym('12')+tf^3*b/sym('6')+tf*b*(d+tf)^2/sym('2'))-d/sym('2')+tf;
sol_d = solve(y==0,d)
f1 = matlabFunction(sol_d(1));
f2 = matlabFunction(sol_d(2));
Mx = 4;
b = 2;
tf = 4;
tw = 20;
d1 = f1(Mx,b,tf,tw)
d2 = f2(Mx,b,tf,tw)
댓글 수: 1
Walter Roberson
2022년 3월 11일
After that you can subs() a vector of Mx values into sol_d to get the solutions relative to those Mx values.
카테고리
도움말 센터 및 File Exchange에서 Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
