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.
6 views (last 30 days)
Show older comments
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
1 Comment
Accepted Answer
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
SYED IMTIAZ ALI SHAH
on 11 Aug 2019
Below is the code, it may not be very efficient (Time constraint) however it will work.
% Center of Mohr Circle
sigma_x = 7;
sigma_y = 5;
sigma_c = (sigma_x+sigma_y)/2;
% Center = (sigma_c,0)
shear_t = 3;
% Radius of Mohr Circle
r = sqrt(((sigma_x-sigma_y)/2)^2+shear_t^2);
twotheta = atan(shear_t/((sigma_x-sigma_y)/2));
theta = twotheta/2;
theta_2 = 0:1:360;
theta_2 = theta_2.*pi/180;
x = r*cos(theta_2)+sigma_c;
y = r*sin(theta_2);
sigma_1 = max(x);
sigma_2 = min(x);
Sx = [sigma_x shear_t];
Sy = [sigma_y -shear_t];
% all points together
allpoints = [sigma_c 0; sigma_1 0; sigma_2 0; sigma_x shear_t; sigma_y -shear_t];
plot(sigma_1,0,'o','LineWidth',2,'color','k')
hold on
plot(sigma_2,0,'o','LineWidth',2,'color','k')
plot(sigma_c,0,'o','LineWidth',2,'color','k')
plot([Sx(:,1) Sy(:,1)],[Sx(:,2) Sy(:,2)],'LineWidth',2,'color','k')
plot(x,y)
labels = {'C','P Str','P Str','B','A'};
labelpoints(allpoints(:,1), allpoints(:,2),labels,'SE',0.5,1)
grid on
axis equal
More Answers (1)
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
0 Comments
See Also
Categories
Find more on Earth and Planetary Science in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!