[Scilab-users] evaluate matrix in a function
philippe
rouxph.22 at gmail.com
Tue Oct 10 08:56:11 CEST 2017
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
More information about the users
mailing list