MATLAB: Calculate absolute maxima and minima of a two variable function

2-d surfacefunctionMATLAB

I have a function
% f(x,y) = x^4 + y^4 - x^2 - y^2 + 1
but i am not able to understand how to start solving this. Can someone help me with the code?

Best Answer

OK, here is the function, but exactly what does "solve" mean to you???
xMin = -2;
xMax = 2;
yMin = -2;
yMax = 2;
numPoints = 200;
xv = linspace(xMin, xMax, numPoints);
yv = linspace(yMin, yMax, numPoints);
[x, y] = meshgrid(xv, yv);
% f(x,y) = x^4 + y^4 - x^2 - y^2 + 1
fprintf('Creating function.\n');
f = x.^4 + y.^4 - x.^2 - y.^2 + 1;
fprintf('Creating surface plot.\n');
surf(x, y, f, 'LineStyle', 'none');
xlabel('x', 'FontSize', 20);
ylabel('y', 'FontSize', 20);
zlabel('f', 'FontSize', 20);
title('f(x,y) = x^4 + y^4 - x^2 - y^2 + 1', 'FontSize', 20);
colorbar;
Do you want to use contour() or contour3() to find out where it equals some value?
Related Question