2.
Finite Difference Method
clc; clear; close all;
% Given parameters
E = 210e9; % Young's modulus (Pa)
L = 7; % Beam length (m)
q0 = 1500; % Uniform load (N/m)
N = 100; % Number of points
dx = L/(N); % Step size
I = 6.4e-6; % Moment of inertia (m^4)
% Finite Difference Matrix
A = zeros(N, N);
b = zeros(N, 1);
% Apply finite difference approximation
for i = 2:N-1
A(i, i-2:i+2) = [1 -4 6 -4 1] / dx^4;
b(i) = q0 / (E*I);
end
% Boundary conditions
A(1,1) = 1; b(1) = 0; % w(0) = 0
A(N,N) = 1; b(N) = 0; % w(L) = 0
A(2,2) = 1; b(2) = 0; % M(0) = 0
A(N,N) = 1; b(N) = 0; % M(L) = 0
% Solve the system
w = A\b;
% Plot results
x = linspace(0, L, N);
plot(x, w, 'b', 'LineWidth', 2);
xlabel('Length of Beam (m)');
ylabel('Deflection (m)');
title('Beam Deflection using Finite Difference Method');
grid on;
3. Centroid of Cross-Section
% Define section dimensions
b1 = 0.01; % Base width (m)
h1 = 0.145; % Base height (m)
b2 = 0.115; % Top width (m)
h2 = 0.01; % Top height (m)
% Compute centroid
A1 = b1 * h1;
A2 = b2 * h2;
y1 = h1 / 2;
y2 = h1 + h2 / 2;
y_centroid = (A1*y1 + A2*y2) / (A1 + A2);
disp(['Centroid Y-coordinate: ', num2str(y_centroid)]);
4. Moment of Inertia Calculation
% Moment of inertia of both sections
I1 = (b1*h1^3)/12;
I2 = (b2*h2^3)/12;
% Parallel axis theorem
I1_total = I1 + A1 * (y_centroid - y1)^2;
I2_total = I2 + A2 * (y_centroid - y2)^2;
I_total = I1_total + I2_total;
disp(['Moment of Inertia: ', num2str(I_total), ' m^4']);
5. Bending Moment and Shear Force
% Shear Force V(x) and Bending Moment M(x)
x = linspace(0, L, N);
V = q0 * (L - x);
M = (q0/2) * (L*x - x.^2);
% Plot
figure;
subplot(2,1,1);
plot(x, V, 'r', 'LineWidth', 2);
xlabel('Beam Length (m)'); ylabel('Shear Force (N)');
title('Shear Force Diagram');
grid on;
subplot(2,1,2);
plot(x, M, 'b', 'LineWidth', 2);
xlabel('Beam Length (m)'); ylabel('Bending Moment (Nm)');
title('Bending Moment Diagram');
grid on;
6. Stress Calculation at K and H
% Maximum moment
M_max = max(M);
y_K = y_centroid;
y_H = y_centroid - h1;
sigma_K = M_max * y_K / I_total;
sigma_H = M_max * y_H / I_total;
disp(['Stress at K: ', num2str(sigma_K), ' Pa']);
disp(['Stress at H: ', num2str(sigma_H), ' Pa']);