Question: MATLAB CODE NOT WORKING: its supposed to show the level curves and calculate the solution with the gradient method the function is f(x)=(x1-1)^+(x2-1)^2 olo =

MATLAB CODE NOT WORKING: its supposed to show the level curves and calculate the solution with the gradient method

the function is f(x)=(x1-1)^+(x2-1)^2

MATLAB CODE NOT WORKING: its supposed to show the level curves and

olo = olo olo olo 0 %ECODE THAT SHOWS LEVEL CURVES (CONTOUR LINES) figure; hold on; x1 -12:0.1:12; x2 = -5:0.1:5; |(x1,x2] = meshgrid(x1,x2); 2 = (X1.-1)^2 + (x2.-1)^2; FUNCTION [C,h] =contour (x1,x2,2, 20); %%%END OF CODE CODE THAT OPTIMIZES x = [7.6;-4.1]; %%INITIAL POINT plot (x(1), (2),'*') DRAW INITIAL POINT Gf = [2*x (1)-2;2*x (2)-2]; %%GRADIENT pause while norm (Gf)>0.1 STOP CONDITION IX = -Gf; % DIRECTION: GRADIENT METHOD t = 0.1;%%EXACT CHANGE x = x + t*IX; %%NEW ITERATION Gf = [2*x (1)-2;2*x (2) -2];%%GRADIENT plot (x (1), (2),'*') % %DRAW NEW POINT pause end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!