Mohr's Circle 98% success
itsLu
matlab
2 years ago
3.9 kB
10
Indexable
Sigma_x = app.Sigma_xEditField.Value;
Sigma_y = app.Sigma_yEditField.Value;
Shear = app.ShearEditField.Value;
RotationAngle = app.RotationAngleEditField.Value;
Sigma_x1 = ((Sigma_x+Sigma_y)/2) + (((Sigma_x-Sigma_y)/2)*cosd(2*RotationAngle)) + (Shear*sind(2*RotationAngle));
Sigma_y1 = ((Sigma_x+Sigma_y)/2) - (((Sigma_x-Sigma_y)/2)*cosd(2*RotationAngle)) - (Shear*sind(2*RotationAngle));
Shear_xy = ((-(Sigma_x-Sigma_y)/2)*sind(2*RotationAngle)) + (Shear*cosd(2*RotationAngle));
Sigma1 = ((Sigma_x+Sigma_y)/2) + sqrt((((Sigma_x-Sigma_y)/2)^2)+ Shear^2);
Sigma2 = ((Sigma_x+Sigma_y)/2) - sqrt((((Sigma_x-Sigma_y)/2)^2)+ Shear^2);
a=Sigma_x-Sigma_y;
b=Shear;
c=2*(b/a);
d=atand(c);
Theta_p1=d/2;
Theta_p2 = Theta_p1+90;
%Theta_p1 = (atan((2*Shear)/(Sigma_x-Sigma_y)))/2;
%Theta_p2 = (atan((2*Shear)/(Sigma_x-Sigma_y)))/2 +90;
MaximumShear = sqrt((((Sigma_x-Sigma_y)/2)^2)+ Shear^2);
s = atand(-a/(2*b));
Theta_s1 = s/2;
Theta_s2 = Theta_s1;
if Theta_s1 > 0
Theta_s2 = Theta_s2 - 90;
elseif Theta_s1 < 0
Theta_s2 = Theta_s2 + 90;
else
Theta_s2 = 90;
end
%Theta_s = (atan(-(Sigma_x-Sigma_y)/(2*Shear)))/2;
app.Sigma_x1EditField.Value = Sigma_x1;
app.Sigma_y1EditField.Value = Sigma_y1;
app.Shear_xyEditField.Value = Shear_xy;
app.Sigma1EditField.Value = Sigma1;
app.Sigma2EditField.Value = Sigma2;
app.Theta_p1EditField.Value = Theta_p1;
app.Theta_p2EditField.Value = Theta_p2;
app.MaximumShearEditField.Value = MaximumShear;
app.Theta_s1EditField.Value = Theta_s1;
app.Theta_s2EditField.Value = Theta_s2;
% Computing Radius and Center of the circle
R=sqrt(((Sigma_x-Sigma_y)/2)^2+Shear^2);
C=(Sigma_x+Sigma_y)/2;
Sigma = linspace(Sigma2, Sigma1, 1001);
% Plot both positive and negative shear stress on app.UIAxes
plot(app.UIAxes, Sigma, Shear, 'b', Sigma, -Shear, 'b');
% Customize axes labels and properties
xlabel(app.UIAxes, 'Sigma');
ylabel(app.UIAxes, 'Shear Stress');
% Fix aspect ratio to ensure circle looks correct
axis(app.UIAxes, 'equal');
% Add diameters for principal stresses and initial stress state
hold(app.UIAxes, 'on');
Ax = Sigma_x;
Ay = Shear;
Bx = Sigma_y;
By = -Shear;
Cx = Sigma_x1;
Cy = Shear_xy;
Dx = Sigma_x1;
Dy = Shear_xy;
DDx = Sigma_y1;
DDy = -Shear_xy;
plot(app.UIAxes, [Ax, Bx], [Ay, By], 'r');
%plot(app.UIAxes, [Bx, Cx], [By, Cy], 'r');
plot(app.UIAxes, [Cx, Dx], [Cy, Dy], 'g');
plot(app.UIAxes, [Dx, DDx], [Dy, DDy], 'g');
%plot(app.UIAxes, [Sigma1, Sigma2], [0, 0], 'k');
%plot(app.UIAxes, [Sigma_x, Sigma_y], [-Shear, Shear], 'r');
%plot(app.UIAxes, [Sigma_x, Sigma_y], [Shear, -Shear], 'g');
% Draw Mohr's circle
viscircles(app.UIAxes, [C, 0], R, 'Color', 'r');
% (Optional) Enable grid for better visualization
grid(app.UIAxes, 'on');
% Release the hold on app.UIAxes
hold(app.UIAxes, 'off');Editor is loading...
Leave a Comment