用MATLAB作:针对函数f(x)=sin(x)^2+x^2⼀100 ,画出在(-10,10)的图

2025-03-24 00:11:27
推荐回答(1个)
回答1:

t=-10:0.1:10;
y=sin(t).^2+t.^2/100;
plot(t,y),grid on,hold on
title('f(x)=sin(x)^2+x^2/100图像及最小值点')
x1=-10:1.5:10;
f=@(x)sin(x).^2+x.^2/100;
for k=1:length(x1)
x0=x1(k);
[x,fval]=fminsearch(f,x0);
plot(x,fval,'r*')
end
按上面程序试试