%Created by Mechanical Attraction :)

clear
close all

%{
Comparing 1mm thick cantilever beams of:
304 stainless
6061 T6 Aluminum
Nylon 6/6

To show differences because material properties
%}

%Constants for 6061 T6 Aluminum
E1=68.9*10^9; %Pa
q1=2700; %Kg/m^3
%Constants for T-304 Stainless Steel
E2=193*10^9; %Pa
q2=8000; %Kg/m^3
%Constants for Nylon 6/6
E3=2.9*10^9; %Pa
q3=1.15*10^3; %Kg/m^3

%Other constants
h=0.001;%Meters in thickness
b=0.0254; %Base in meters but makes no difference (cancels out)
A=b*h;
I=b*h^3/12;
c=(1.875^2)/(2*pi); %Constant

%Varying Length
L=.001:.0001:.5; %Meters length

%Solution
Wn(1,:)=c*sqrt((E1*I)./(q1*A*L.^4));
Wn(2,:)=c*sqrt((E2*I)./(q2*A*L.^4));
Wn(3,:)=c*sqrt((E3*I)./(q3*A*L.^4));

L_inches=L*(39.3701); %Unit conversion

%Plotting
figure(1)
plot(L_inches,Wn)
legend('6061 T6 Aluminum','T-304 Stainless Steel','Nylon 6/6')
title('1mm thick natrual vibrations of various materials');
xlabel ('Length of beam, Inches');
ylabel ('Natural frequency, Hz');
ylim([0 150]);
xlim([0 10]);