how to calculate a difference of function with any parameter
1 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Torsten
2022-1-8
编辑:Torsten
2022-1-8
function main
h = 1e-6;
xleft = -pi;
xright = pi;
n = 200;
dx = (xright-xleft)/n;
x = xleft:dx:xright;
change_in_y_by_change_in_x = (f(x+h)-f(x))/h;
plot(x,change_in_y_by_change_in_x)
hold on
plot(x,cos(x)) % for comparison, plot (sin(x))' = cos(x)
end
function y = f(x)
y = sin(x)
end
7 个评论
Torsten
2022-1-8
Please include the function f in which you calculate "N" dependent on "da" callable as
N = f(da)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!