title: vector as output for matlab function
body: <p>I am new to Matlab.</p>
  
  <p>I am doing Extended Kalman Filter simulation which requires calculating Jacobians(partial differenciation functions) for a given function. I am using a function to get the Jacobian values:</p>
  
  <pre><code>function [H] = jacobH(x1,x2)
  H = [ -(2*x1(1,:,:) - 2*x2(1,:,:))/(8*pi*((x1(1,:,:) - x2(1,:,:))^2 + (x1(3,:,:) - x2(3,:,:))^2)^(3/2)), 0,
        -(2*x1(3,:,:) - 2*x2(3,:,:))/(8*pi*((x1(1,:,:) - x2(1,:,:))^2 + (x1(3,:,:) - x2(3,:,:))^2)^(3/2)), 0];
  end
  </code></pre>
  
  <p>The Jacobian basically differenciates 1/(4*pi*sqrt((x1-x2)^2+(y1-y2)^2)) wrt x,y</p>
  
  <p>Eg, If I am passing jacobH(x1(:,1,1), x2(:,1,1)) then I should get H as a 1x4 matrix with [value1, 0, value2, 0]. value1 and value2 varies for different inputs.</p>
  
  <p>But I am getting only one value. I don't know where I went wrong.</p>
  
  <p>I searched for similar questions but none of them are relevant to my issue.</p>
  
  <p>Also, Is there a more efficient way to do this?</p>
  
  <p>Any help is appreciated!</p>