[Scilab-users] evaluate matrix in a function

Hermes herozigle at gmail.com
Sat Oct 7 20:10:26 CEST 2017


Hello
The H and g functions work. But the diffcode_jacobian (H, r) evaluation does
not accept the dot operator. Only redefining the H function (without dot
operators) will achieve the results

function val = HH(z)
    x=z(1);
    y=z(2); 
    val=(1.25*y-sqrt(abs(x)))^2+x^2-1; // switched *.^* to *^* 
endfunction;


t=[3. 1.]
disp(diffcode_jacobian(HH,t));

-->6.2783122
  -1.205127

J=[];
for k=1:size(r,"r")
    J(k,:)=diffcode_jacobian(HH,r(k,:)); 
  end
disp(J, "Jacobian");

-->Jacobian

   6.2783122  -1.205127 
   7.75            1.25     
   3.3915608   11.294873
   16.116117  -0.8210678

disp(and(J==g))
-->F   Why? The results of J and g look the same !!

g

   6.2783122  -1.205127 
   7.75             1.25     
   3.3915608   11.294873
   16.116117  -0.8210678

   
 J

   6.2783122  -1.205127 
   7.75            1.25     
   3.3915608   11.294873
   16.116117  -0.8210678

Gracias




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html



More information about the users mailing list