是否可以使用输入命令输入函数以使用numderivative?

Is it possible to use the input command to enter functions in order to use numderivative?

我一直在研究求解多项式和非多项式方程的数值方法。我想使用 numderivative 来计算用户输入的函数的定义导数,代码如下:

clc
clear 
x0 =input('Enter the x value: ') // x0 = 4
function y = f(x)
    y = input('Enter your function: ') // y = sqrt(x)
endfunction
dd = numderivative(f,x0)
printf('The definite derivative value of f(x) in x = %d is %.6f',x0,dd)

不可以输入函数,但是可以输入函数的指令:

x0 =input('Enter the x value: ') // x0 = 4 
instr = input('Enter the expression to derivate as a function of x: ',"s")//sqrt(x)
deff("y=f(x)","y="+instr)

dd = numderivative(f,x0)
printf('The definite derivative value of f(x) in x = %d is %.6f',x0,dd)