手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

向前差商法求导y=sin(x)

时间:2024-10-12 00:41:28

1、新建.m文件,命名为'sin_derivation.m'

2、clear;clc;a = -5;b = 5;h = 0.1;x = a:h:b;n = length(x);y1 = sin(x);颊俄岿髭dydx = zeros(1,n-1);for k= 1:n-1 dydx(k) = (sin(x(k+1))-sin(x(k)))/h;endfigure(1)plot(x,y1)hold onplot(x(2:n),dydx(1:(n-1)))hold offlegend('sin(x)','dydx')

3、运行程序并得到y' = cos(x)的结果

向前差商法求导y=sin(x)
© 手抄报圈