使用Matlab求解代数方程

时间:2016-05-15 22:21:51

标签: matlab

我有一个非常复杂的等式,我试图求解直径,变量d。我之前从未使用过Matlab,但这是我唯一可用的资源。所以对于一个基本的例子......

eq = 40;
eq = 1+((2*d)/3);
answer = solve(d)

我之前在vba中编程,我不确定Matlab的正确语法

1 个答案:

答案 0 :(得分:-2)

感谢您的帮助,但我明白了。

 syms d eq; 
 eq = 40
 eqn = 1+((2*d)/3)-eq==0; 
 solve(eqn,d)

完整的问题。

 syms d eq Ktaxial Ktbending Kttorsion p1 p2 T sigxpoint1 sigxpoint2 Transhear torxypoint1 torxypoint2 torshear pie M Length Bending Area Q I;
 %Loading level 1
 eq = 41904.7617; %Constant
 Ktaxial = 1.95; %Constant
 Ktbending = 1.7; %Constant
 Kttorsion = 1.45; %Constant
 P1 = 9453; %Change
 P2 = 493; %Change
 T = 298; %Change
 Length = 22; %Constant

 %Constants, do not change
 pie = 3.141592654;
 Area = ((pie/4)*(d)^2);
 Ybar = ((2*d)/(3*pie));
 Q = (Area/2)*(Ybar);
 I = ((pie/64)*(d)^4);
 M = P2*Length;
 Bending = Ktbending*((32*M)/(pie*(d)^3));
 sigaxial = ((P1/Area))*Ktaxial;
 torshear = ((16*T)/(pie*(d)^3))*Kttorsion;
 Transhear = ((P2*Q)/(I*d));
 %Calculate Stresses
 sigxpoint1 = (sigaxial+Bending);
 torxypoint1 = (torshear);
 sigxpoint2 = (sigaxial);
 torxypoint2 = (Transhear+torshear);
 %Final Equations
 point1 = (sqrt(((sigxpoint1)^2)+3*(torxypoint1)^2))-eq == 0;
point2 = (sqrt(((sigxpoint2)^2)+3*(torxypoint2)^2))-eq == 0;
 %Solve
 double(solve(point1,d))
 double(solve(point2,d))