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 (최근 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
SYED IMTIAZ ALI SHAH 2019년 8월 10일
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
SYED IMTIAZ ALI SHAH 2019년 8월 11일
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에서 Stress and Strain에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by