Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun = @(x) 4*x(1)-x(2)^2-12;
- h1(x1,x2) = 25 - x1^2 - x2^2;
- g2(x1,x2) = 10*x1 - x1^2 + 10*x2 - x2^2 - 34;
- g3(x1,x2) = x1;
- g4(x1,x2) = x2;
- % draw the function
- xval = 0:0.1:7;
- yval = 0:0.1:7;
- funval = zeros(numel(xval));
- i = 1;
- while( i <= length(xval) )
- j = 1;
- while( j <= length(yval) )
- funval(i,j) = fun([xval(i), yval(j)]);
- j = j + 1;
- end
- end
- i = i + 1;
- end
- plot(x(1), x(2), 'r*'); % punkturinn
- hold on;
- % bæti við g2
- fimplicit(@(x1,x2) -x1^2 + 10*x1 - x2^2 + 10*x2 - 34, [0 7 0 7]);
- %plotta contour
- contour(xval, yval,funval);
- % bæti við jöfnunni h1
- %contour(h1val, yval,funval);
- xlim([0,7]);
- ylim([0,7]);
- circle(0,0,5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement