title: How to fix: "anonymous function bodies must be single expressions" error on Octave
body: <p>I am trying to make a function in Octave where you give octave a function f(x,y) as a string, a change in X, a change in Y, a starting point, and the size of a matrix, the function will create a matrix populated with the values of f(x,y) at each point in the matrix. </p>
  
  <p>This is for an application that displays a 3d graph, using the matrix to map each value to a block</p>
  
  <pre><code># funcStr: The function whose Z values are being calculated
  # dx: the change in x that each block in the x direction represents
  # dy: the change in y that each block in the y direction represents
  # startPt: the point (in an array of x, y) that center block represents
  # res: the side length (in blocks) of the plane
  
  pkg load symbolic
  syms x y
  function[zValues] = calculateZValues(funcStr, dx, dy, startPt, res)
  
  zValues = zeros(res);
  eqn = @(x, y) inline(funcStr);
  
  startX = startPt{1};
  startY = startPt{2};
  
  for yOffset = 1:res
      for xOffset = 1:res
          xCoord = startX + dx * xOffset;
          yCoord = startY + dy * yOffset;
          zValues(res * yOffset + xOffset) = double(subs(eqn, @(x, y), {xCoord, yCoord}));
      endfor
  endfor
  endfunction
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <pre><code>&gt;&gt; calculateZValues("x*y", 1, 1, {0,0}, 10)
  parse error near line 20 of file /home/rahul/Documents/3dGraph/graph/calculateZValues.m
  
    anonymous function bodies must be single expressions
  
  &gt;&gt;&gt;             zValues(res * yOffset + xOffset) = double(subs(eqn, @(x, y), {xCoord, yCoord}));
  </code></pre>
  
  <p>I have no idea what the issue is. I have replaced the @(x,y) part with {x,y} in the line referenced by the error but it says nothing or it raises an error about the function <code>subs</code> not being declared. I have also tried moving the <code>pkg</code> and <code>syms</code> lines above the function header</p>