Question 2
z = @(x,y) (x.^2 + y - 11).^2 + (x.^2 + y - 7).^2; %% question (a) r = -5:0.1:5; [X,Y] = meshgrid(r,r); contour(X,Y, z(X,Y), LevelStep=5) %% question (b) hold on fimplicit(@(x,y) x + y) %% question (c) fmincon(@(x) z(x(1), x(2)), [1 1], [] ,[] , [1, 1], 0) title("Question 2") xlabel("x") ylabel("y")