matlab看不懂.function y=f(x) y=1./x+2*sin((2*x).^0.5);end >> format long>> x=3.3;h=0.1;g=(f(x+h)-2*f(x)+f(x-h))/(h^2) g = -0.009399348448680 >> x=3.3;h=0.001;g=(f(x+h)-2*f(x)+f(x-h))/(h^2) g = -0.009377437715230 >> x=3.3;h=0.001;g=(f(x+h)-2*
来源:学生作业帮助网 编辑:六六作业网 时间:2025/02/02 23:19:46
matlab看不懂.function y=f(x) y=1./x+2*sin((2*x).^0.5);end >> format long>> x=3.3;h=0.1;g=(f(x+h)-2*f(x)+f(x-h))/(h^2) g = -0.009399348448680 >> x=3.3;h=0.001;g=(f(x+h)-2*f(x)+f(x-h))/(h^2) g = -0.009377437715230 >> x=3.3;h=0.001;g=(f(x+h)-2*
matlab看不懂.
function y=f(x)
y=1./x+2*sin((2*x).^0.5);
end
>> format long
>> x=3.3;h=0.1;
g=(f(x+h)-2*f(x)+f(x-h))/(h^2)
g =
-0.009399348448680
>> x=3.3;h=0.001;
g=(f(x+h)-2*f(x)+f(x-h))/(h^2)
g =
-0.009377437715230
>> x=3.3;h=0.001;
g=(f(x+h)-2*f(x)+f(x-h))/(h^2)
g =
-0.009377437715230
matlab看不懂.function y=f(x) y=1./x+2*sin((2*x).^0.5);end >> format long>> x=3.3;h=0.1;g=(f(x+h)-2*f(x)+f(x-h))/(h^2) g = -0.009399348448680 >> x=3.3;h=0.001;g=(f(x+h)-2*f(x)+f(x-h))/(h^2) g = -0.009377437715230 >> x=3.3;h=0.001;g=(f(x+h)-2*
代码定义了一个函数:f(x) =1/x + 2*sin(√(2x))
里面的下标“.” 表示当x为数组时,预算是对数组成员分别进行的.
下面f(x+h)相当于把3.3001代入上面的函数,f(x) f(x-h)也一样.
format long 表示改变了精度.