title: Matlab/Octave function handlers and nargin
body: <p>I am writing program in Octave and I encountered a problem, I implemented Gauss-Legandre Quadrature and I pass to my Gauss-Legandre function few arguments, and I pass the function to be intergrated in a cell cube, so I can pass few function at a time. I have this piece of code:</p>
  
  <pre><code>    for weight=1:length(w)
          temp=1; 
          for fun=1:length(c)
              %liczenie iloczynu f(x_i)g(x_i), x_i - pieriwastki wielomianu Legandra
              f=c{fun};
              nargin(func2str(c{fun}))
              if (nargin (func2str(c{fun})) == 1)
                  disp('a');
                  temp*=c{fun}((b-a)/2 * x(weight) + (a+b)/2);
              else
                      (b-a)/2 * x(weight) + (a+b)/2;  
                  temp*=f((b-a)/2 * x(weight) + (a+b)/2,I,points);
              end
          end
          %mnozenie wyniku przez odpowiedni wspolczynnik - wage
          temp*=w(weight);
          result+=temp;
      end
  </code></pre>
  
  <p>In cell array there are function handlers to functions which I want to integrate. Depending on number of arguments that function takes i want to use two different calls for function. If in cell array there is handler to a function that is written in .m file in the same directory as my Octave working directory everything works fine, but when i define function in Octave running time, for example:</p>
  
  <pre><code>    function result=a(x)
      result=x*x
      end
  </code></pre>
  
  <p>Type</p>
  
  <pre><code>    c{1}=@a
  </code></pre>
  
  <p>and pass this cell array to my function Kwadratury there is an error of nargin</p>
  
  <pre><code>    error: nargin: invalid function
      error: called from:
  </code></pre>
  
  <p>Why is that and how can I solve it, so I can define function not only in .m files but also in Octave.</p>