First derivative in matlab
<p>I want to calculate the first derivative of a function with matlab. However, I do not know the function's formula, I only have access to its inputs and outputs.
For instance:</p>

<pre><code>f([1 2 3 4 5]) = [1 4 9 16 25]; %Square function for the example
</code></pre>

<p>I am not satisfied of the output of:</p>

<pre><code>diff([1 2 3 4 5]) %Which is [3 5 7 9]
</code></pre>

<p>I have seen on this forum that I am not the only one trying to calculate the first derivative of a function with matlab. But since, I don't know the mathematical formula of my function, I can't use the symbolic Math Toolbox.</p>

<p>So my questions are:</p>

<ul>
<li>How can I calculate the derivative of a function in matlab by only knowing its inputs and outputs?</li>
<li>Can I find a way to retrieve the mathematical formula of my function, so that I can use the symbolic Math Toolbox?</li>
</ul>

<p>Thank you for your help.</p>