Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
me3255_finalproject_group29/problem_4.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
105 lines (98 sloc)
3.6 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Problem 5 | |
clear | |
clc | |
% Set the default text and plot size according to this script. | |
setdefaults | |
% Young's Modulus for aluminum [Pascals]: | |
E = 70e9; | |
% Width of beam [meters]: | |
b = 0.1; | |
% Height of beam [meters]: | |
h = 0.01; | |
% Second moment of inertia [meters^4]: | |
I = (b*h.^3)/12; | |
% Density of aluminum beam [kg/m^3]: | |
rho = 2700; | |
% Cross sectional area of the beam [m^2]: | |
A = b*h; | |
%-------------------------------------------------------------------------- | |
% Define the 6 segment matrix: | |
% Segment length for 6 segments | |
h_6 = 1/6; | |
A_6 = zeros(5); | |
b_6 = zeros(5,1); | |
% Diagonal vectors of the A matrix: | |
ones_vect_6 = ones(3,1); | |
fours_vect_6 = -4*ones(4,1); | |
sixes_vect_6 = 6*ones(5,1); | |
% Create A matrix by summing the diagonal vectors. | |
A_6 = diag(ones_vect_6,-2) + diag(fours_vect_6,-1) + diag(sixes_vect_6) + diag(ones_vect_6,2) + diag(fours_vect_6,1); | |
A_6(1,1) = 5; | |
A_6(5,5) = 5; | |
% Solve the eigenvalue problem using Matlab's "eig" function to return | |
% eigenvectors and eigenvalues. | |
[eig_6,lamb_6] = eig(A_6); | |
% Find natural frequency | |
omeg_6 = sqrt((lamb_6 * E * I)/(rho*A*h_6^4))'/2/pi; | |
% Plotting the shape of the beam | |
x_plot_6 = 0:1/4:1; | |
figure; | |
plot(x_plot_6,eig_6(:,1:3)); | |
title('Shape of Beam for First 3 Natural Frequencies: \newline Beam Deflection vs. Horizontal Distance\newline \it 6 Segments'); | |
xlabel('x [m]'); | |
ylabel('Beam Deflection [m]'); | |
legend('\omega_{1}', '\omega_{2}', '\omega_{3}','Location','southeastoutside'); | |
%------------------------------------------------------------------------------- | |
% Define the 10 segment matrix: | |
% Segment length for 10 segments | |
h_10 = 1/10; | |
A_10 = zeros(9); | |
b_10 = zeros(9,1); | |
% Diagonal vectors of the A matrix: | |
ones_vect_10 = ones(7,1); | |
fours_vect_10 = -4*ones(8,1); | |
sixes_vect_10 = 6*ones(9,1); | |
% Create A matrix by summing the diagonal vectors. | |
A_10 = diag(sixes_vect_10)+diag(fours_vect_10,-1)+diag(fours_vect_10,1)+diag(ones_vect_10,-2)+diag(ones_vect_10,2); | |
A_10(1,1) = 5; | |
A_10(9,9) = 5; | |
% Solve the eigenvalue problem using Matlab's "eig" function to return | |
% eigenvectors and eigenvalues. | |
[eig_10,lamb_10] = eig(A_10); | |
% Find natural frequency | |
omeg_10 = sqrt((lamb_10 * E * I)/(rho*A*h_10^4))'/2/pi; | |
% Plotting the shape of the beam | |
x_plot_10 = 0:1/8:1; | |
figure; | |
plot(x_plot_10,eig_10(:,1:3)); | |
title('Shape of Beam for First 3 Natural Frequencies: \newline Beam Deflection vs. Horizontal Distance\newline \it 10 Segments'); | |
xlabel('x [m]'); | |
ylabel('Beam Deflection [m]'); | |
legend('\omega_{1}', '\omega_{2}', '\omega_{3}','Location','southeastoutside'); | |
%-------------------------------------------------------------------------- | |
% Define the 20 segment matrix: | |
% Segment length for 20 segments | |
h_20=1/20; | |
A_20 = zeros(19); | |
b_20 = zeros(19,1); | |
% Diagonal vectors of the A matrix: | |
sixes_vect_20 = 6*ones(1,19); | |
fours_vect_20 = -4*ones(1,18); | |
ones_vect_20 = ones(1,17); | |
% Create A matrix by summing the diagonal vectors. | |
A_20 = diag(sixes_vect_20)+diag(fours_vect_20,-1)+diag(fours_vect_20,1)+diag(ones_vect_20,-2)+diag(ones_vect_20,2); | |
A_20(1,1) = 5; | |
A_20(19,19) = 5; | |
% Solve the eigenvalue problem using Matlab's "eig" function to return | |
% eigenvectors and eigenvalues. | |
[eig_20,lamb_20] = eig(A_20); | |
% Find natural frequency | |
omeg_20 = sqrt((lamb_20 * E * I)/(rho*A*h_20^4))'/2/pi; | |
% Plotting the shape of the beam | |
x_plot_20 = 0:1/18:1; | |
figure; | |
plot(x_plot_20,eig_20(:,1:3)); | |
title('Shape of Beam for First 3 Natural Frequencies: \newline Beam Deflection vs. Horizontal Distance\newline \it 20 Segments'); | |
xlabel('x [m]'); | |
ylabel('Beam Deflection [m]'); | |
legend('\omega_{1}', '\omega_{2}', '\omega_{3}','Location','southeastoutside'); |