title: Double integral of objective function
body: <p>I want to evaluate the double integral of my objective function (named <code>myfunction</code>, see below) using the build-in-function <code>integral2</code>. </p>
  
  <p>I have tried to run this script;</p>
  
  <pre><code>f = @(r,theta) myfunction(r,theta);
  integral2(f,0,2,0,2*pi);
  </code></pre>
  
  <p>where <code>myfunction</code> is the following function:</p>
  
  <pre><code>function fkt=myfunction(r,theta)
  x=r.*cos(theta);
  y=r.*sin(theta);
  los(:,1)=x;
  los(:,2)=y;
  norm = (sum( sqrt( los(:,1).^2 + los(:,2).^2)));
  fkt=norm*r;
  end
  </code></pre>
  
  <p>I am making the integral in polar coordinates, that why  <strong>fkt=norm*r</strong>. </p>
  
  <p>Matlab gives me the following error message:</p>
  
  <pre><code>&gt;&gt; untitled2
  Subscripted assignment dimension mismatch.
  
  Error in myfunction (line 8)
  los(:,1)=x;
  </code></pre>
  
  <p>I can't figure out, what the problem is. </p>