[Scilab-users] evaluate matrix in a function

Rafael Guerra jrafaelbguerra at hotmail.com
Tue Oct 10 12:51:39 CEST 2017


Right, and if one follows the thread till the end, how does that apply to diffcode_jacobian ?


-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of philippe
Sent: Tuesday, October 10, 2017 8:56 AM
To: users at lists.scilab.org
Subject: Re: [Scilab-users] evaluate matrix in a function

Hi,

Le 07/10/2017 à 13:05, Hermes a écrit :
> 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"


I'm not sure of what you are asking for. It looks like you want to
evaluate a function f on the curve defined by 2 vectors x,y  instead of
evaluating it on the grid defined by x,y (which is done by feval). If
this is  what you are searching for  you can use something like feval2
below :


function z=feval2(x,y,f)
    //  eval f on the curve t->(x(t),y(t))
    // and on the grid defined by x,y
    deff('z=newf(k)','z=f(x(k),y(k))')
    // x,y are global variables for the "newf" function
    z=feval(1:length(x),newf)
    // "newf" is a local variable for "feval2"
endfunction

then try the example  :


-->deff('z=f(x,y)','z=x.^2-y.^2') // test function

-->x=-3:3;y=x;

-->z=feval(x,y,f)// grid evaluation
 z  =

    0.    5.    8.    9.    8.    5.    0.
  - 5.    0.    3.    4.    3.    0.  - 5.
  - 8.  - 3.    0.    1.    0.  - 3.  - 8.
  - 9.  - 4.  - 1.    0.  - 1.  - 4.  - 9.
  - 8.  - 3.    0.    1.    0.  - 3.  - 8.
  - 5.    0.    3.    4.    3.    0.  - 5.
    0.    5.    8.    9.    8.    5.    0.

-->z=feval2(x,y,f) // curve evaluation
 z  =

    0.    0.    0.    0.    0.    0.    0.

Best regards

Philippe

_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


More information about the users mailing list