%Bike Crank Tutorial - Verification & Validaiton
%Sigma_x along height of cross-section

x = 3.345; %Distance of the cross-section from the left hole (i.e middle of the crank), in inches
y = [0.000E+00
0.0138
0.0276
0.0414
0.0552
0.0690
0.0828
0.0965
0.1103
0.1241
0.1379
0.1517
0.1655
0.1793
0.1931
0.2069
0.2207
0.2345
0.2483
0.2621
0.2758
0.2896
0.3034
0.3172
0.3310
0.3448
0.3586
0.3724
0.3862
0.4000
0.4138
0.4276
0.4414
0.4551
0.4689
0.4827
0.4965
0.5103
0.5241
0.5379
0.5517
0.5655
0.5793
0.5931
0.6069
0.6207
0.6344
0.6482
0.6620]';
y = y-(0.662/2)*ones(1,length(y)); %Y range from -0.33in to 0.33in

%y = [-0.3 -0.2 -0.1 0 0.1 0.2 0.3]; %Input vector of all heights we wish to find stress (0 is at the middle of the crank so the normal stress from bending will be 0 there), in inches
a = 6.69;  %Distance between the support and the load (i.e between the two holes). 
b = 0.375; %The crank thickness in, inches
h = 0.662; %Actual total height of the cross section 
p = 100; %Load

M=-p*(a-x); %Moment, in lbs-in
I=(1/12)*b*h^3; %Moment of inertia
sigma_x=(M.*y/I)' %normal stress in the x-direction, in psi