Info

此问题已关闭。 请重新打开它进行编辑或回答。

1D two linear 2-node element solver

2 次查看(过去 30 天)
John Adams
John Adams 2023-5-14
关闭: John D'Errico 2023-6-18
Hello Everyone,
I am a beginner in matlab and trying to learn fem codding. Can someone help me to solve Problem 4.4 in "A First Course in Finite Elements: Fish, Jacob, Belytschko, Ted" book?
Thank you for your help.
  2 个评论
Dyuman Joshi
Dyuman Joshi 2023-5-14
Please show what you have attempted yet.
John Adams
John Adams 2023-5-14
编辑:John Adams 2023-5-14
% Define the number of elements
numElements = [2, 4, 8];
% Define the exact displacement function
u_ex = @(x) x.^3;
% Initialize arrays to store the errors and element sizes
errors = zeros(size(numElements));
elementSizes = zeros(size(numElements));
% Iterate over different mesh configurations
for i = 1:numel(numElements)
numElems = numElements(i);
elementSize = 1 / numElems;
% Subdivide the interval [0, 1] into elements
x = linspace(0, 1, numElems + 1);
% Initialize arrays for storing the displacements and strains
u_h = zeros(size(x)); epsilon_h = zeros(size(x));
epsilon_ex = zeros(size(x));
% Iterate over each element
for e = 1:numElems
% Define the element nodes
x1 = x(e); x2 = x(e + 1);
% Define the element shape function matrix
N_e = [(x2 - x) / (x2 - x1); (x - x1) / (x2 - x1)];
Actually, I am a bit confused about steps which one I need to do first etc. I know some theoretical aspects like when I compute displacement at 2nd node of 2nd element I should not use 1st element 1st shape function but I could not turn it into code. I need a solution of this example to better understand to topic. Please help, thank you.

回答(0 个)

此问题已关闭。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by