title: How to generate a triangulation for FEM 1D - MATLAB?
body: <p>I'm trying to plot Exact VS FEM solution for this equation:<br>
  <a href="https://i.stack.imgur.com/Jx4Do.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jx4Do.png" alt="Equation"></a></p>
  
  <p>with boundary condition:<br>
  <a href="https://i.stack.imgur.com/QJrNw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QJrNw.png" alt="Boundary Condition"></a></p>
  
  <p>I followed this code for example: <a href="http://www4.ncsu.edu/~zhilin/TEACHING/MA587/MATLAB/1DSIMPLE/drive.m" rel="nofollow noreferrer">Example Code</a></p>
  
  <p>It's fine for its case, but in my case I don't know about how to get the triangulation (for my case) for this line:   </p>
  
  <pre><code>x(1)=0; x(2)=0.1; x(3)=0.3; x(4)=0.333; x(5)=0.5; x(6)=0.75;x(7)=1;   
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>clear all; close all;
  
  x(1)=0*pi; x(2)=0.1*pi; x(3)=0.3*pi; x(4)=0.333*pi; x(5)=0.5*pi; x(6)=0.75*pi;x(7)=1*pi;
  
  U = fem1d(x);
  
  x2 = 0:0.01:pi; k2 = length(x2);
  for i=1:k2,
      u_exact(i) = soln(x2(i));
      u_fem(i) = fem_soln(x,U,x2(i));
  end
  
  error = norm(u_fem-u_exact,inf)
  
  plot(x2,u_fem,':',x2,u_exact)
  hold; plot(x,U,'o')
  xlabel('x'); ylabel('u(x) &amp; u_{fem}(x)');
  title('Solid line: Exact solution, Dotted line: FEM solution')
  
  figure(2); plot(x2,u_fem-u_exact); title('Error plot')
  xlabel('x'); ylabel('u-u_{fem}'); title('Error plot')
  </code></pre>
  
  <p>How to generate the triangulation values? Does anyone know?</p>
  
  <p>Thank you</p>