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.

7 次查看(过去 30 天)
%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

采纳的回答

SYED IMTIAZ ALI SHAH
syms Th;
km = (2*T)/(Sx-Sy);
eq1 = tan(2*Th) == km;
solvth = solve(eq1);
solvth = double(solvth)
Hope this will work
  4 个评论
SYED IMTIAZ ALI SHAH
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

请先登录,再进行评论。

更多回答(1 个)

Douglas Leaffer
Douglas Leaffer 2021-4-5
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

类别

Help CenterFile Exchange 中查找有关 Earth and Planetary Science 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by