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)
%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

Accepted Answer

SYED IMTIAZ ALI SHAH
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
  4 Comments

Sign in to comment.

More Answers (1)

Douglas Leaffer
Douglas Leaffer on 5 Apr 2021
ADD the following function call to your script:
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

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!