title: problem undefined variable in sample program
body: <p>I am new to Octave and have found an interesting article (<a href="http://article.journalofchemicaleducation.com/pdf/wjce-3-6-1.pdf" rel="nofollow noreferrer">http://article.journalofchemicaleducation.com/pdf/wjce-3-6-1.pdf</a>). I copied the code to start playing with it but I can not fond the problem: error: 'x' undefined near line 29 column 12
  error: called from
  diproticbuffer at line 29 column 4
  solvediproticbuffer at line 2 column 1
  solvediproticbuffer.</p>
  <p>Could you please help me.</p>
  <pre><code>function [y] = diproticbuffer(x)
  global c0;
  global pK;
  c0 = 10.^(-x);
  y(1) = 1.0-(x(4)+x(1)-x(3))/pK(1);
  y(2) = 1.0-(x(5)+x(1)-x(4))/pK(2);
  y(3) = 1.0-(x(1)+x(2))/pK(3);
  y(4) = 1.0-(c(5)+c(4)+c(3))/c0(1);
  y(5) = 1.0-(c(2)+c(4)+2*c(5))/(c(1)+c0(2));
  end
  
  clear
  source('diproticbuffer.m');
  global c0;
  c0 = [0.02; 0.015 ];
  global pK;
  pK = [3.46; 5.10; 14.0];
  x0=[ 7; 7; 1.7; 8; 8 ];
  [x, fval, info] = fsolve ('diproticbuffer', x0, optimset('TolFun',1.0E-8));
  fprintf('Equilibrium concentrations\n');
  fprintf('p[H+] = %8.4f-&gt;[H+] = %10.4E\n', x(1), 10^(-x(1)));
  fprintf('p[OH-]= %8.4f-&gt;[OH-]= %10.4E\n', x(2), 10^(-x(2)));
  fprintf('p[H2A]= %8.4f-&gt;[H2A]= %10.4E\n', x(3), 10^(-x(3)));
  fprintf('p[HA-]= %8.4f-&gt;[HA-]= %10.4E\n', x(4), 10^(-x(4)));
  fprintf('p[A2-]= %8.4f-&gt;[A2-]= %10.4E\n', x(5), 10^(-x(5)));
  </code></pre>