[Users-fr] applying function to a matrix
Vincent Douce Mathoscope
mathoscope at netcourrier.com
Ven 2 Fév 11:42:10 CET 2018
hi
i am not very ease with scilab but i have to help some stundents of mine on that topic
i thought that applying any function on a matrix would apply affect every item of that matrix
example sqrt(A) would that the sqrt of each aij of A
in this logic i wanted to simulate a binomial law by creating this bernoulli function :
function xp=f(x, p)
if x<p
then xp=1
else xp=0
end
endfunction
and apply it to a grand of ramdom x in [0,1] like that :
function bn=binomiale(n, p)
a=grand(1,n,"unf",0,1)
ap=f(a,p)
disp(ap)
bn=sum(ap)
endfunction
but it doesn't work
it seems like scilab would try to apply f to a as an object itself
could aynone help me understanding ?
thanks
––––––––––––––––––––––––––
Vincent Douce
:=: Mathoscope :=:
http://mathoscope.xyz
06°13°11°07°26
Bagnères de Bigorre 65200
-------------- section suivante --------------
Une pièce jointe HTML a été nettoyée...
URL: <https://lists.scilab.org/pipermail/users-fr/attachments/20180202/142bcce7/attachment.htm>
Plus d'informations sur la liste de diffusion users-fr