Skip to content
Permalink
ffc36a6153
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
169 lines (136 sloc) 5.3 KB
% Problem 3
clear
clc
setdefaults
% Plug in different values for q to find corresponding deflections.
q = [1,10,20,30,50];
%Plug in different values for P to find corresponding deflections.
P= [0,100,200,300];
% 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;
% Create matrix for plotting for each segment length
w6_max_plot=zeros(4,5);
w10_max_plot=zeros(4,5);
w20_max_plot=zeros(4,5);
for s= 1:4
% 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;
%define Matrix due to force P>0;
P_6=zeros(5);
%Diagonal vectors of the P matrix:
twos_vect_6=-2*ones(5,1);
ones_vect_6=ones(4,1);
% Creating diagonal P matrix by summing diagonal vectors.
P_6=diag(twos_vect_6,0)+diag(ones_vect_6,-1)+diag(ones_vect_6,1);
%multiply matrix by (Ph^2)/(EI)
P_6=((P(s)*(h_6)^2)/(E*I))*P_6;
%define final matrix as A_6 - P_6
A_6=A_6-P_6;
%find unkown w for each segment
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;
% define Matrix due to force P>0;
P_10=zeros(9);
%Diagonal vectors of the P matrix:
twos_vect_10=-2*ones(9,1);
ones_vect_10=ones(8,1);
% Creating diagonal P matrix by summing diagonal vectors.
P_10=diag(twos_vect_10,0)+diag(ones_vect_10,-1)+diag(ones_vect_10,1);
%multiply matrix by (Ph^2)/(EI)
P_10=((P(s)*(h_10)^2)/(E*I))*P_10;
%define final matrix as A_10 - P_10
A_10=A_10-P_10;
%find unkown w for each segment
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);
% 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;
%define Matrix due to force P>0;
P_20=zeros(19);
%Diagonal vectors of the P matrix:
twos_vect_20=-2*ones(19,1);
ones_vect_20=ones(18,1);
% Creating diagonal P matrix by summing diagonal vectors.
P_20=diag(twos_vect_20,0)+diag(ones_vect_20,-1)+diag(ones_vect_20,1);
%multiply matrix by (Ph^2)/(EI)
P_20=((P(s)*(h_20)^2)/(E*I))*P_20;
%define final matrix as A_20 - P_20
A_20=A_20-P_20;
%find unkown w for each segment
w_20 = inv(A_20) * b_20;
w20_max(i) = max(w_20);
%----------------------------------------------------------------------
end
%define max deformation matrix values for the current load
w6_max_plot(s,:)=w6_max;
w10_max_plot(s,:)=w10_max;
w20_max_plot(s,:)=w20_max;
end
% Plot q vs. max deflection for each segment size. There will be three
% different graphs, each corresponding to a different segment size.
% each graph will show 4 different lines representing the four different
% applied loads.
figure
plot(w6_max_plot(1,:),q,'-o',w6_max_plot(2,:),q,'-o',w6_max_plot(3,:),q,'-o',w6_max_plot(4,:),q,'-o');
title(['Maximum Deflection for 6 segments \newline at Varying Distributed Loadings'])
xlabel('\delta_{x} [m]')
ylabel('q [N/m]')
legend('\delta_{x} for P=0', '\delta_{x} for P=100','\delta_{x} for P=200','\delta_{x} for P=300','Location','southeast')
figure
plot(w10_max_plot(1,:),q,'-o',w10_max_plot(2,:),q,'-o',w10_max_plot(3,:),q,'-o',w10_max_plot(4,:),q,'-o');
title(['Maximum Deflection for 10 segments \newline at Varying Distributed Loadings']);
xlabel('\delta_{x} [m]')
ylabel('q [N/m]')
legend('\delta_{x} for P=0', '\delta_{x} for P=100','\delta_{x} for P=200','\delta_{x} for P=300','Location','southeast')
figure
plot(w20_max_plot(1,:),q,'-o',w20_max_plot(2,:),q,'-o',w20_max_plot(3,:),q,'-o',w20_max_plot(4,:),q,'-o');
title(['Maximum Deflection for 20 segments \newline at Varying Distributed Loadings'])
xlabel('\delta_{x} [m]')
ylabel('q [N/m]')
legend('\delta_{x} for P=0', '\delta_{x} for P=100','\delta_{x} for P=200','\delta_{x} for P=300','Location','southeast')