How to use pcg with a function in MATLAB
<p>I am going to solve an inverse problem, <code>AX=b</code>, using conjugate gradient method in MATLAB. I want to use <code>pcg</code> function in MATLAB and as I know instead of matrix <code>A</code> I can use a function. </p>

<p>I have a function for example <code>afun</code> which has some entries. In the documents, I have seen that the <code>afun</code> function is entered in <code>pcg</code> function without entries, however, when I do the same, the error <code>not enough input arguments</code> appears.  I use a code like this:</p>

<pre><code>b = afun(ent1,ent2);
x = pcg(@afun,b,tol,max_iter);
</code></pre>

<p>How should I use my function in <code>pcg</code>?</p>