From 63d9c85ffa2142904eac5f8158f1063703dc7b06 Mon Sep 17 00:00:00 2001 From: Sebastian Donoso Date: Sun, 30 Apr 2017 23:00:58 -0400 Subject: [PATCH] Adding second half --- PlotSSS.m | 23 ++++++++++++++++++++ plotCDM_Part_2.m | 20 ++++++++++++++++++ plotCDM_Part_3.m | 48 ++++++++++++++++++++++++++++++++++++++++++ setdefaults.m | 3 +++ shape_simple_support.m | 17 +++++++++++++++ solveODE.m | 18 ++++++++++++++++ 6 files changed, 129 insertions(+) create mode 100644 PlotSSS.m create mode 100644 plotCDM_Part_2.m create mode 100644 plotCDM_Part_3.m create mode 100644 setdefaults.m create mode 100644 shape_simple_support.m create mode 100644 solveODE.m diff --git a/PlotSSS.m b/PlotSSS.m new file mode 100644 index 0000000..795ddef --- /dev/null +++ b/PlotSSS.m @@ -0,0 +1,23 @@ +function PlotSSS(maxLoad) +%Generates deflections based on all values of distributed load from 1 to +%inputted value maxLoad, plots output of deflection against load + +%Given physical parameters +q = [1:maxLoad]; %initialize array of loads for plotting +w = zeros(1,maxLoad); %initialize array of deflections for plotting +x = 0.5; %location of maximum deflection (constant for all q) + +%Iterate function for all values of q +for n = 1:maxLoad + %Place max deflections in an array w + w(n) = -shape_simple_support(x,n); +end + +%Plotting routine +plot(q,w) +setdefaults +xlabel('Applied Load (N/m)') +ylabel('Max Deflection (m)') +title('Applied Load versus Maximum Deflection') +end + diff --git a/plotCDM_Part_2.m b/plotCDM_Part_2.m new file mode 100644 index 0000000..2af2ec3 --- /dev/null +++ b/plotCDM_Part_2.m @@ -0,0 +1,20 @@ +%Problem 2a-d +clear; +clc; + +%iterates through each number of segments and applied load to fin three +%vectors of values of deflection for each load +N = [6,10,20]; +q = [1,10,20,30,50]; +data = zeros(3,5); +for n = [1:3] + for m =[1:5] + data(n,m) = max(CDM(q(m),N(n),0)); + end +end + +%Plotting routine for Part 2 +plot(q,data(1,:),q,data(2,:),q,data(3,:)); +ylabel('Deflection (meters)') +xlabel('Applied Load q (N/m)') +title('Deflection vs. Applied Load q') diff --git a/plotCDM_Part_3.m b/plotCDM_Part_3.m new file mode 100644 index 0000000..9ea2586 --- /dev/null +++ b/plotCDM_Part_3.m @@ -0,0 +1,48 @@ +N = [6,10,20]; +q = [1,10,20,30,50]; +P = [0,100,200,300]; + +for n = [1:4] + for m =[1:5] + data_6(n,m) = max(CDM(q(m),6,P(n))); + end +end +subplot(1,3,1) +plot(q,data_6(1,:),q,data_6(2,:),q,data_6(3,:),q,data_6(4,:)); +%Plotting q vs. x_distance_vector +ylabel('Deflection (meters)') +%sets proper bounds for x axis +xlabel('Applied Load q (N/m)') +%set Proper bounds for y axis +title('Deflection vs. Applied Load q (6 Segments)') +%Title of the graph. + +for n = [1:4] + for m =[1:5] + data_10(n,m) = max(CDM(q(m),10,P(n))); + end +end +subplot(1,3,2) +plot(q,data_10(1,:),q,data_10(2,:),q,data_10(3,:),q,data_10(4,:)); +%Plotting q vs. x_distance_vector +ylabel('Deflection (meters)') +%sets proper bounds for x axis +xlabel('Applied Load q (N/m)') +%set Proper bounds for y axis +title('Deflection vs. Applied Load q (10 Segments)') +%Title of the graph. + +for n = [1:4] + for m =[1:5] + data_12(n,m) = max(CDM(q(m),12,P(n))); + end +end +subplot(1,3,3) +plot(q,data_12(1,:),q,data_12(2,:),q,data_12(3,:),q,data_12(4,:)); +%Plotting q vs. x_distance_vector +ylabel('Deflection (meters)') +%sets proper bounds for x axis +xlabel('Applied Load q (N/m)') +%set Proper bounds for y axis +title('Deflection vs. Applied Load q (12 Segments)') +%Title of the graph. \ No newline at end of file diff --git a/setdefaults.m b/setdefaults.m new file mode 100644 index 0000000..905e14b --- /dev/null +++ b/setdefaults.m @@ -0,0 +1,3 @@ +set(0,'defaultAxesFontSize',16) +set(0,'defaultTextFontSize',14) +set(0,'defaultLineLineWidth',3) \ No newline at end of file diff --git a/shape_simple_support.m b/shape_simple_support.m new file mode 100644 index 0000000..c703c86 --- /dev/null +++ b/shape_simple_support.m @@ -0,0 +1,17 @@ +function w = shape_simple_support(x,q) +%Takes input of x (position) and q (applied distributed load) +%and calculates the deflection of the beam at a point + +%Given physical parameters +E = 70*10^9; %Pa - elastic modulus +l = 1; %m - beam length +b = 0.1; %m - beam width +h = 0.01; %m - beam height + +%Derived variables +I = (b*(h^3))/12; %m^4 - moment of inertia + +%Deflection calculated at x (in meters) +w = (((q*l*(x^3))/(12*E*I)))-(((q*(x^4))/(24*E*I)))-((q*(l^3)*x)/(24*E*I)); +end + diff --git a/solveODE.m b/solveODE.m new file mode 100644 index 0000000..281d617 --- /dev/null +++ b/solveODE.m @@ -0,0 +1,18 @@ +%Initialize Constants +E = 70*10^9; %Pa +dens = 2700; %kg/m^3 +b = 0.1; %m +h = 0.01; %m +l = 1; %m + +%Derived variables +I = (b*(h^3))/12; % m^4 +area = b*h; %m^2 + +[x,w] = ode45(@defl,[0 1],[0;0.001;0;-0.1]); +plot(x,w(:,1),'-o',x,w(:,2),'-o') +title('Depiction of Beam Deflection with ODE45'); +xlabel('Position x (m)'); +ylim([-0.001 0.001]) +xlim([0 1]) +ylabel('Deflection (m)');