[Scilab-users] evaluate matrix in a function

Hermes herozigle at gmail.com
Sat Oct 7 18:39:34 CEST 2017


Hello
The H function works. the other two evaluations did not solve the problem.

function val = H(z)
    x=z(:,1);
    y=z(:,2); 
    val=(1.25*y-sqrt(abs(x))).^2+x.^2-1; // switched ^ to .^ to handle
vectors
endfunction;


function Sys=g(x)
  gx=x(:,1);
  gy=x(:,2);  
g1=2*gx-(gx  *(1.25*gy-sqrt(abs(gx))))/abs(gx).^(3/2);
g2=2.5*(1.25*gy-sqrt(abs(gx)));
  Sys(:,1)=g1;
  Sys(:,2)=g2;
endfunction

r=[3 1;4 2;3 5;8 2]
disp(H(r),"H");
H

   8.232373
   15.25
   28.411865
   63.107864

V=g(r');
disp(V,"g");
J = diffcode_jacobian(H,r);
disp(J, "Jacobian");

at line     4 of function g ( E:\Heart Curve8.sce line 28 )
at line    36 of executed file E:\Heart Curve8.sce

*Inconsistent row/column dimensions.
*
Gracias



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



More information about the users mailing list