% FEACM solution Example 2.1
clear all
syms x x1 x2 h E A f real
% shape functions (linear Lagrange polynomial)
N(1)=(x-x2)/(x1-x2)
N(2)=(x-x1)/(x2-x1)
N=subs(N,{x1,x2},{0,h})
% Strain-displacement matrix B
B=diff(N,x)
% Stiffness matrix
K_e = int(B'*E*B,x,0,h)*A
% Equivalent nodal force vector
P_e=int(f*N,0,h)
