# Hey there, I am trying to write a code for 2D-Mohr's circle and i need to generate a circle for x value of Sx, radius(r) of T.

8 views (last 30 days)
Syed Mustaqhim on 10 Aug 2019
Answered: Douglas Leaffer on 5 Apr 2021
%this is the code(incomplete) for 2D Mohrs circle, looking for assistance.
Sx = input('Enter value of stress in x direction in N/mm2: ');
Sy = input('Enter value of stress in y direction in N/mm2: ');
T = input('Enter value of shear stress in N/mm2: ');
%Maximum and Minimum principal stress, Maximum shear stress
S1 = ((Sx+Sy)/2) + sqrt((((Sx-Sy)/2)^2) + (T^2))
S2 = ((Sx+Sy)/2) - sqrt((((Sx-Sy)/2)^2) + (T^2))
Tm = sqrt((((Sx-Sy)/2)^2) + (T^2))
syms Th;
eq1 = tan(2*Th) == ((2*T)/(Sx-Sy));
Th = solve(eq1, Th)
% Im having a problem outputting Th in numeric values
darova on 10 Aug 2019
It is math. The question has nothing to do with MATLAB  SYED IMTIAZ ALI SHAH on 10 Aug 2019
syms Th;
km = (2*T)/(Sx-Sy);
eq1 = tan(2*Th) == km;
solvth = solve(eq1);
solvth = double(solvth)
Hope this will work
Syed Mustaqhim on 14 Aug 2019
Thanks a lot!

Douglas Leaffer on 5 Apr 2021
circle((S1+S2)/2, 0, Tm) % function call
Then create a new function and save to the same (current) folder as your script:
function h = circle(x,y,r)
hold on
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
h = plot(xunit, yunit);
grid on
hold off
end