Plotting 1D Quadratic FEM Solution

200 Views Asked by At

I am solving an ODE $$ u''= -x^2 $$ from $0\leq x \leq 1$, using Dirichlet boundary conditions; $$ \left\{ \begin{array}{cl} u(0)&=0 \\ u(1)&= 0.01 \end{array} \right. $$ using 1D quadratic FEM in MATLAB. I am using Lagrange quadratic interpolation as my basis functions. I know in 1D quadratic fem, each element has three nodes, $n$ elements and $2n+1$ nodes. I am solving for $u$ and in the end I am getting solution values for each node.

Now I want to plot these solution points with respect to Nodes over the analytical solution. I am using plot(Nod,u) where Nod is the number of nodes and u is the solution data values for each node, MATLAB is making straight lines instead of making curves. Does any body knows how to make curve using Nodes and solution points, so my solution looks like quadratic instead of linear? thanks!