用matlab绘制以下函数图形并求极值 1、y=x^3-3x+2,(0≤x≤10) 2、z=x^2-(y-1)^2,(0≤x≤10,0≤y ≤2)
时间: 2023-04-12 15:00:35 浏览: 418
matlab用法.pdf
好的,我可以回答这个问题。以下是用 MATLAB 绘制函数图形并求极值的代码:
1、
syms x
y = x^3 - 3*x;
fplot(y, [0, 10]);
grid on;
hold on;
fplot(diff(y), [0, 10]);
fplot(-diff(y), [0, 10]);
xlabel('x');
ylabel('y');
legend('y = x^3 - 3x', 'y'' = 3x^2 - 3', 'y'' = -3x^2 + 3');
title('y = x^3 - 3x');
2、
syms x y
z = x^2 - (y - 1)^2;
f = @(x, y) x^2 - (y - 1)^2;
fcontour(f, [0, 10, 0, 2]);
grid on;
xlabel('x');
ylabel('y');
title('z = x^2 - (y - 1)^2');
[x0, y0] = solve([diff(z, x) == 0, diff(z, y) == 0], [x, y]);
disp(['The extreme point is (', num2str(x0), ', ', num2str(y0), ')']);
希望这个回答能够帮到你!
阅读全文