0% found this document useful (0 votes)
57 views

% % Output: % Y: Beam Deflection % Inputs: % L: Length of The Beam % N: Number of Positions % W: Load % I: Moment of Inertia % E: Young Modulus

The document describes a Matlab function that calculates beam deflection given the beam's length, number of positions, load, moment of inertia, and Young's modulus. It defines inputs and outputs, sets parameter values, generates position vectors, initializes deflection vectors, then calculates deflection at each position in a loop using a beam deflection formula. It plots the undeformed and deformed beam configurations.

Uploaded by

James Leung
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

% % Output: % Y: Beam Deflection % Inputs: % L: Length of The Beam % N: Number of Positions % W: Load % I: Moment of Inertia % E: Young Modulus

The document describes a Matlab function that calculates beam deflection given the beam's length, number of positions, load, moment of inertia, and Young's modulus. It defines inputs and outputs, sets parameter values, generates position vectors, initializes deflection vectors, then calculates deflection at each position in a loop using a beam deflection formula. It plots the undeformed and deformed beam configurations.

Uploaded by

James Leung
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Matlab coursework

function y=beamDeflection(L,N)
%
% Output:
% y: Beam deflection
% Inputs:
% L: Length of the beam
% N: Number of positions
% w: Load
w=3721;
% I: Moment of inertia
I=879.45*10^-8;
% E: Young modulus
E=2.3*10^11;
% vector
x = linspace(0,L,N);
%vectors for deformed and undeformed
y0=zeros (1,N);
y=zeros (1,N);
% Loop
for i=1:N
y(i)=-((w*x(i)^(2))/(120*L*E*I))*((10*L^(3))-(10*L^(2)*x(i))
+(5*L*x(i)^(2))-(x(i)^(3)));
end

% Represent the two configurations


plot (x,y0,'b','LineWidth',2)
hold on
plot (x,y,'r','Linewidth',2)
% Add a legend
legend ('Undeformed','Deformed')
xlabel ('Position [m]')
ylabel ('Deflection [m]')
title ('Beam defelection')

question 2
function [x,s]=finiteSeries(M)
% Inputs:
% M: summation of series
% Outputs:
% x:vector
% s:real number
x=zeros(1,M);
% Intialise the sum
s=0;
% Loop
for n=1:M
x(n)=2^(n);
s=x(n);
end

Question 3
function xk=sequenceStNumber()
% Inputs:
StNumber=742148
% Ouputs:
xk
n=[-2:3:2000];
xk=0;
c=1000
for r=1:c
z=((2*n^(4))+(15*n^(2))-2)/(n-2)

Question 4
function [y, xMax, yMax]= beamMaximumDelfection(L)
%
% Inputs:
% L: maximum beam deflection
% w:load
w=2986
% I: moment of inertia
% E: Young modulus
E=1.8*10^(11)
% Outputs:
% y: Vector of the deflections of 100 equally distributed points
% xMax: position where maximum deflection is attained
% yMax: maximum deflection
a=L/2

You might also like