- I am a new user of
Scilab
and I am not a mathematician. - As my end goal, I want to calculate (and plot) the derivative of a piece-wise defined function, see here.
- I tried to start small and just use a simple (continuous) function:
f(x) = 3*x
. - My Google-Fu lead me to the numderivative function.
- Problem: It seems that I do not understand how the argument
x
works since the result is not a 1D-array, instead, it is a matrix. - Update 1: Maybe I use the wrong function and
diff
is the way to go. But what is then the purpose ofnumderivative
?
PS: Is this the right place to ask Scilab-related questions? It seems that there are several StackOverflow communities where Scilab-related questions are asked.
// Define limits
x0 = 0;
x1 = 2;
// Define array x for which the derivative will be calculated.
n = 100;
x = linspace (x0, x1, n);
// Define function f(x)
deff('y=f(x)','y=3*x');
// Calculate derivative of f(x) at the positions x
myDiff = numderivative(f,x)
(I expect the result 3 3
and not a matrix.)