You are on page 1of 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