New Main
New Main
legend('exact','FEM linearArea')
title('axial stress')
ylabel('axial stress , \sigma')
xlabel('x')
axis([2 6 0 60])
hold off
shapeFunctionLx
function [shape,naturalDerivatives] = shapeFunctionLx(location,L)
syms iop
xe=linspace(-1,1,L);
shape_function = sym(zeros(size(xe)));
for index = 1 : length(shape_function)
xi = xe(index);
xj = xe(xe ~= xi);% reture which not equal xi
shape_function(1, index) = prod((iop-xj) ./ (xi-xj));
end
shape=double(subs(shape_function,iop,location));
naturalDerivatives=double...
(subs(diff(shape_function,iop),iop,location));
end
shapeFunctionLxx
function [J,shape,naturalDerivatives] = ...
shapeFunctionLxx(location,L,array)
% array = nodeCoordinates(elementDof)
syms iop
xe=linspace(-1,1,L);
shape_function = sym(zeros(size(xe)));
for index = 1 : length(shape_function)
xi = xe(index);
xj = xe(xe ~= xi);% reture which not equal xi
shape_function(1, index) = prod((iop-xj) ./ (xi-xj));
end
% J=subs(shape_function*array',iop,0);
shape=double(subs(shape_function,iop,location));
naturalDerivatives=double...
(subs(diff(shape_function,iop),iop,location));
J=subs(diff(shape_function,iop)*array',iop,0);
end