% Frank Fisher
% Von Mises stresses calculations
% Based on 'Design of Machine Elements, 8th ed.' by Spotts et al
% see page 136

clear
clc

% enter in the stress matrix here... a few good examples included below
sigma=[70, 30, 25; 30, 80, 40; 25, 40, 90];  %from the Spotts text, pg 134, ex 2.2
%sigma=[100, 0, 0; 0 20 0; 0, 00, 00];   %reduction in vm stress
%sigma=[100, 0, 0; 0 -50 0; 0, 00, 00];  %increase in vm stress

disp('Please confirm your stress matrix. Hit key to continue ');
disp(sigma)
pause

princ_stresses=eig(sigma);      %eigenvalues give you three principle stresses
S1=princ_stresses(1);
S2=princ_stresses(2);
S3=princ_stresses(3);

disp('principle stresses are... ');
disp(princ_stresses);

% calculate the von mises stresses
vm=sqrt(S1^2 + S2^2 + S3^2 - S1*S2 - S1*S3 - S2*S3);

disp('Von Mises stresses are... ');
disp(vm);

% Note: in Spotts pg 136 - they give the value of vm^2 in the text
% A little bit confusing at first...