Matlab diff(F,var,n) vs Python numpy diff(a, n=1, axis=-1)
<p>I am trying to calculate matlab function in python.</p>

<pre><code>y = diff(x,1,2)
</code></pre>

<p>x is and grayscale image </p>

<p>i tried numpy diff function but i get different answer</p>

<p>please help</p>

<p>in the comment to your question, it appears you swapped the arguments to the <code>diff</code> functions. However, the documentation states that both in matlab and in numpy, the order of the arguments is:</p>

<ul>
<li><p>array</p></li>
<li><p>n</p></li>
<li><p>dimension</p></li>
</ul>

python matlab numpy scipy