Drawing Shape Function of Quadratic element (1D) or Beam element

This code may help you to draw the shape function in Finite Element Analysis
242 Downloads
Updated 1 Dec 2015

View License

% This code can use for ploting shape function of
% Quadratic Element (One Dimensional Problem)
% Beam element
clc; clear all; close all
x_e = 0;
h_e = 1;
Phi_0 = zeros(10,1);
Phi_1 = zeros(10,1);
Phi_2 = zeros(10,1);
Phi_3 = zeros(10,1);
Phi_4 = zeros(10,1);

Case = input('Type 1 for Quadratic Element (1D), Type 2 for Beam Element ');
n = 0;
if Case == 1
% Quadratic Element (1D Problem)
for x = 0:.1:1
n = n+1;

phi_1 = (1-(x)/h_e)*(1-(2*x)/h_e);
phi_2 = 4*(x)/h_e*(1-(x)/h_e);
phi_3 = -(x)/h_e*(1-(2*x)/h_e);

Phi_0(:,n) = 0; % This Draws axis line
Phi_1(:,n) = phi_1;
Phi_2(:,n) = phi_2;
Phi_3(:,n) = phi_3;
end

plot (0:.1:1,Phi_1','c')
hold on
plot (0:.1:1,Phi_2','g')
plot (0:.1:1,Phi_3','r')
plot (0:.1:1,Phi_0','k')

else
% Beam element
for x = 0:.1:1
n = n+1;

phi_1 = 1-3*((x-x_e)/h_e).^2+2*((x-x_e)/h_e).^3;
phi_2 = -(x-x_e)*(1-((x-x_e)/h_e)).^2;
phi_3 = 3*((x-x_e)/h_e).^2-2*((x-x_e)/h_e).^3;
phi_4 = -(x-x_e)*(((x-x_e)/h_e).^2-((x-x_e)/h_e));

Phi_0(:,n) = 0; % This Draws axis line
Phi_1(:,n) = phi_1;
Phi_2(:,n) = phi_2;
Phi_3(:,n) = phi_3;
Phi_4(:,n) = phi_4;
end

plot (0:.1:1,Phi_1','c')
hold on
plot (0:.1:1,Phi_2','g')
plot (0:.1:1,Phi_3','r')
plot (0:.1:1,Phi_4','b')
plot (0:.1:1,Phi_0','k') % This Draws axis line
end

Cite As

Sajeer Modavan (2024). Drawing Shape Function of Quadratic element (1D) or Beam element (https://www.mathworks.com/matlabcentral/fileexchange/54253-drawing-shape-function-of-quadratic-element-1d-or-beam-element), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Quadratic Programming and Cone Programming in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0