clear all

n = 100
A = zeros(n,n);

for i=1:n
  x(i) = i-1;
  
  % heat source (-ive sign for positive heat)
  f(i) = 0;
  
  f(i) = -x(i)*x(i)*1e-5;
  
  f(i) = - sin(x(i)*100);
  
  if i == 1
    % left boundary
    f(i) = 0;
    A(i,i) = 1;
  elseif i == n
    % right boundary
    f(i) = 0;
    A(i,i) = 1;
  else 
      A(i,i-1) = 1;
      A(i,i) = -2;
      A(i,i+1) = 1;
  end
end

% Fixed Heat flow
% f(5) = -1


T = inv(A)*f';

plot(x,T)
