How to apply mathematical function on arrays and vectors and multidimensional matric

question

#1

Hi guys,

I am quite new to Julia, I come form matlab background. I wanted to know how can you apply any mathematical fuunction like sine, cos or besselh to a matrix or array.

for example in matlab say you have x = rand(3,4,5) and you do y=sin(x) what you get is y a 3d matrix having dimension of (3,4,5). How can you accomplish this julia ?


#2
y = sin.(x)

For more details see “broadcast and vectorization” in:

https://docs.julialang.org/en/v1/base/arrays/index.html

and

https://docs.julialang.org/en/v1/manual/functions/index.html


#3

I guess you want to read https://docs.julialang.org/en/v1/manual/functions/#man-vectorized-1 in particular.


#4

Thanks so much this helps a lot :slight_smile: