In: Computer Science
Implement the working of a mohr circle in matlab. ask user to enter the stresses in x and y direction. take the inputs to a stress tensor. then use formulations to find the eigen value and vectors.
MATLAB
% Center of Mohr Circle
sigma_x =input('Enter value of stress in x direction in N/mm2: ');
sigma_y = input('Enter value of stress in y direction in N/mm2: ');
sigma_c = (sigma_x+sigma_y)/2;
% Center = (sigma_c,0)
shear_t = input('Enter value of shear stress in N/mm2: ');
% 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
Note: Plzzz don' t give dislike.....Plzzz comment if u have any problem i will try to resolve it.......