syms x y zeqn1 = (a-principle_stress(i,1))*x + p*y + r*z == 0eqn2 = p*x + (b-principle_stress(i,1))*y + q*z == 0eqn3 = r*x + q*y + (c-principle_stress(i,1))*z == 0eqn4 = (x*x) + y*y + z*z == 1eqns=[eqn1,eqn2,eqn3,eqn4];S = solve(eqns,[x y z])
This is a part my code, when I run the code with inputs a=b=c=r=q=1 and p=2 along with principle_stress(i,1)=3.7321, I get the output as
eqn1 = 2*y - (6152031499462239*x)/2251799813685248 + z == 0 eqn2 = 2*x - (6152031499462239*y)/2251799813685248 + z == 0
But this is not something I want, I need a simpleified version which shows the equation taking only upto 2 decimal points.
Also I have 3 variables and 4 equations, is it acceptable?
Here is my code:
prompt='Give the value of the first normal stress(sigma_x):';a=input(prompt);prompt='Provide the value of the second stress(sigma_y):';b=input(prompt);prompt='The value of the first shearing stress acting(sigma_z):';c=input(prompt);prompt='The value of the first shearing stress acting(Tau_xy):';p=input(prompt);prompt='Give the value of the first normal stress(Tau_yz):';q=input(prompt);prompt='Provide the value of the second stress(Tau_zx):';r=input(prompt);Ten=[[a,p,r];[p,b,q];[r,q,c]]%finding the invariants
L1=a+b+cL2=(a*b)+(b*c)+(c*a)-(p*p)-(q*q)-(r*r)L3=det(Ten)polynomial=[1,-L1,L2,-L3]principle_stress=roots(polynomial)Direction_cosine=zeros(3,1);i=1%while i<3
syms x y zdigits = 5;eqn1 = (a-principle_stress(i,1))*x + p*y + r*z == 0eqn2 = p*x + (b-principle_stress(i,1))*y + q*z == 0eqn3 = r*x + q*y + (c-principle_stress(i,1))*z == 0eqn4 = (x*x) + y*y + z*z == 1eqns=[eqn1,eqn2,eqn3,eqn4];S = vpasolve(eqns,[x y z])S.z%Direction_cosine(i,1)=S
i=i+1;%end
Best Answer