All All: %somil Yadav 2116208 %asignment 6

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

%Somil Yadav

%32116208
%Asignment 6

clear all
close all
clc

% defining variables and constans


L = 9;
w1 = 10000;
w2 = 50000; %load is linerly dispributed from w1 to w2
w3 = w2-w1;
W = (w1+w2)*L/2; %total load over the beam
E = 210*10^9;
I = 961.25*10^-6;

% discretizing the bar


divi=100;
nnodes=divi+1;
dx=L/divi;
h=dx;
x=0:dx:L;

%to find the reactions we take moment on A, sumation(Ma)=0


Rb = w1*L/2+w3*L/3;
Ra = W-Rb;

% Shear Force Calculation


V = zeros(nnodes,1);

for i=1:nnodes
V(i) = Ra -w1.*x(i)-(0.5*w3.*(x(i)^2))/L;
xaxis = 0;
plot(x,V);
xlabel("Length");
ylabel("Shear Force");
title("Shear Force Diagram");
end
% Calculating the Bending Moment using numerical method

K = zeros(nnodes); %stiffness matrix [101 X 101]


F = zeros(nnodes,1); %force matrix [101 x 1]

%defining w (load distibution/variation)


w = zeros(nnodes,1);

for a = 1:nnodes
w(a) = w3.*x(a)/L + w1;
end

% Calculating the Bending Moment using numerical method

K = zeros(nnodes); %stiffness matrix [101 X 101]


F = zeros(nnodes,1); %force matrix [101 x 1]

for i=2:nnodes-1

%get the right hand side


F(i)= h^2*(-w(i));

%save coeff at proper locations


K(i,i-1) = 1; %previous
K(i,i)= -2; %present
K(i,i+1)= 1; %next
end

% setting up the boundary conditions

K(1,1) = 1;
K(nnodes,nnodes) = 1;
F(1) = 0;
F(nnodes) = 0;

% solving and ploting


M=K\F; %find bending moment
plot(x,M,"r","LineWidth",2);
xlabel("length");
ylabel("bending Moment");

%finding maximum bending moment and its position


[BM,idx] = max(M);
disp("Maximumum value of Bending Moment is " + BM + " Nm^2 at l= " + x(idx) +
" mm")
Maximumum value of Bending Moment is 307395 Nm^2 at l= 4.95 mm
%calculating the Deflection using numerical method

EI = E*I*ones(1,nnodes); %EI
k = zeros(nnodes); %stiffness matrix [101 x 101]
f = zeros(nnodes,1); %force matrix [101 x 1]

for i=2:nnodes-1

%get the right hand side


f(i)= h^2*M(i)/EI(i);

%save coeff at proper locations


k(i,i-1) = 1; %previous
k(i,i)= -2; %present
k(i,i+1)=1; %next
end

%setting up boundary conditions

k(1,1) = 1;
k(nnodes,nnodes) = 1;
f(1) = 0;
f(nnodes) = 0;

defl=k\f; %find deflection


plot(x,defl,"g","LineWidth",2);
xlabel("length");
ylabel("deflection");
title("Deflection Diagram")
%finding maximum deflection and its position
[y,idx] = min(defl);
x(idx);
maxdeflmm = -y*1000;
disp("maximum deflection in mm is ymax= " + maxdeflmm + "mm at l= " + x(idx) +
" m")
maximum deflection in mm is ymax= 12.7069mm at l= 4.59 m

You might also like