Hi Hermes,
I do not recall your problem and it would help some explanation.
To plot the contours of a gradient with contour2d, you have to make it a scalar
(otherwise look at champ, etc.).
Check out the edited code below.
Note that your gradient does not reach 0 and so a contour |g|=5 is plotted.
// START OF CODE
clear; clf;
funcprot(0);
function val=H(x1, x2)
val=(1.25*x2-sqrt(abs(x1))).^2+x1.^2-1;
endfunction;
function [gx, gy]=g(x1, x2)
gx= 2*x1-(x1.*(1.25*x2-sqrt(abs(x1))))./abs(x1).^(3/2);
gy = 2.5*(1.25*x2-sqrt(abs(x1)));
endfunction
function val=HH(z)
x1=z(1);
x2=z(2);
val=(1.25*x2-sqrt(abs(x1))).^2+x1.^2-1;
endfunction;
function z=dH(x)
z=numderivative(HH,x)
endfunction
//test
x0=[0.2 -0.5];
disp(H(x0(1),x0(2)));
[gx,gy]=g(x0(1),x0(2))
disp(gx,gy);
disp(dH(x0));
x = linspace(-1,1,1002);
y = 2*x';
xx = x.*.ones(x');
yy = y.*.ones(y');
[gx,gy] = g(xx,yy);
g1= abs(gx + %i*gy);
contour2d(x, y, g1, [5 5]);
replot([-1.415,-1,1.415,1.415]);
// END OF CODE
[cid:[email protected]]
Regards,
Rafael
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users