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_2.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
94 lines (85 sloc)
2.97 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 3 | |
clear | |
clc | |
setdefaults | |
% Plug in different values for q to find corresponding deflections. | |
q = [1,10,20,30,50]; | |
% 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; | |
% Plotting q vs. max deflection: | |
for i = 1:5 | |
%---------------------------------------------------------------------- | |
% Define the 6 segment matrix: | |
% Segment length for 6 segments | |
h_6 = 1/6; | |
A_6 = zeros(5); | |
b_6 = ((h_6^4*q(i))/(E*I))*ones(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 for the deflection vector by inv(A) * b | |
w_6 = inv(A_6) * b_6; | |
w6_max(i) = max(w_6); | |
%---------------------------------------------------------------------- | |
% Define the 10 segment matrix: | |
% Segment length for 10 segments | |
h_10 = 1/10; | |
A_10 = zeros(9); | |
b_10 = ((h_10^4*q(i))/(E*I))*ones(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 for the deflection vector by inv(A) * b | |
w_10 = inv(A_10) * b_10; | |
w10_max(i) = max(w_10); | |
%---------------------------------------------------------------------- | |
% Define the 20 segment matrix: | |
% Segment length for 20 segments | |
h_20=1/20; | |
A_20 = zeros(19); | |
b_20 = ((h_20^4*q(i))/(E*I))*ones(19,1); | |
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 for the deflection vector by inv(A) * b | |
w_20 = inv(A_20) * b_20; | |
w20_max(i) = max(w_20); | |
%---------------------------------------------------------------------- | |
end | |
% Plot q vs. max deflection for each segment size. There will be three | |
% different graphs, each corresponding to a different segment size. | |
figure | |
plot(w6_max,q,'-o') | |
title('Distributed Beam Loading vs. Maximum Deflection for 6 segments'); | |
xlabel('\delta_{x} [m]'); | |
ylabel('q [N/m]'); | |
figure | |
plot(w10_max,q,'-o'); | |
title('Distributed Beam Loading vs. Maximum Deflection for 10 segments'); | |
xlabel('\delta_{x} [m]'); | |
ylabel('q [N/m]'); | |
figure | |
plot(w20_max,q,'-o'); | |
title('Distributed Beam Loading vs. Maximum Deflection for 20 segments'); | |
xlabel('\delta_{x} [m]'); | |
ylabel('q [N/m]'); | |