繁体   English   中英

我很难找到一个代码来估计 sin(x) 在 x=pi/4 处的二阶导数,h^-1 在八度音阶

[英]I struggle to find a code to estimate the second derivative of sin(x) at x=pi/4 with h^-1 in octave

我试过函数句柄如下:

f=@(f(x+h)-2*(f(x))+(f(x-h)))./h^2;

我得到解析错误:

无效的参数列表

f=@(f(x+h)-2*(f(x))+(f(x-h)))./h^2;

我尝试在 x=pi/4 处估计 sin(x) 的二阶导数,其中 h^-1 以八度为单位。

我找不到用 h^-1 估计 x=pi/4 处 sin(x) 的二阶导数的代码

匿名函数定义为:

f= @(parameters)(function);

你忘记添加参数了。 我怀疑你想要:

f=@(x)((f(x+h)-2*(f(x))+(f(x-h)))./h^2);

但是,这会导致第二个问题:您正在覆盖f 也许你想要

% you defined some f=@(x)...
g=@(x)((f(x+h)-2*(f(x))+(f(x-h)))./h^2);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM