Francesco Azzollini
Francesco Azzollini

Reputation: 9

Dividing arrays in IDL and sum over array elements

I was wondering how to divide two arrays

a = [1,2,3,4,5]
b = [2,4,6,8,15]

to get

a/b = [0.5,0.5,0.5,0.5,0.3]

Thanks in advance for the help.

Upvotes: -1

Views: 256

Answers (2)

user22265185
user22265185

Reputation: 1

Just express the arrays as floating variables or doubles, then you will get the desired results. Otherwise, the results will come as 0.0 as it rounds up to the lowest integer. I hope it will work.

Upvotes: 0

mgalloy
mgalloy

Reputation: 2386

Most operations in IDL are performed element-wise, so doing c = a / b will do what you want here.

Upvotes: 0

Related Questions