[Scilab-users] evaluate matrix in a function

Rafael Guerra jrafaelbguerra at hotmail.com
Sat Oct 7 14:34:29 CEST 2017


Your code has the solution (for the matrix function output).

Do the same for input:


r=[3 1;4 2;3 5;8 2];

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



Regards,

Rafael



-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Hermes
Sent: Saturday, October 07, 2017 1:05 PM
To: users at lists.scilab.org
Subject: [Scilab-users] evaluate matrix in a function



how do I declare the functions to be able to evaluate a matrix

variable(Multiple evaluation of a function). Where the first column

corresponds to the first variable of the function. And so on.

is only possible within a "for" cycle? how to declare the function to be

able to use the operator "dot"



r=[3 1;4 2;3 5;8 2];



function val = H(z)

    x=z(1);

    y=z(2);

    val=(1.25*y-sqrt(abs(x)))^2+x^2-1;

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



V=g(r)';

disp(V,"g");

J = diffcode_jacobian(H,r);

disp(J, "Jacobian");



Gracias

Hermes


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20171007/2147fb1d/attachment.htm>


More information about the users mailing list