-1

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.

GhostCat
  • 137,827
  • 25
  • 176
  • 248
  • Please be careful when **tagging** your questions, "idl" isnt the same as "idl-programming-language". Also note: in general, people here HELP you solving problems. So it is always better to **first** try things yourself, instead of just dropping your (home)work assignment here. You learn programming by programming, not by delegating the heavy lifting to other people. – GhostCat Feb 23 '22 at 15:00

2 Answers2

0

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

mgalloy
  • 2,356
  • 1
  • 12
  • 10
0

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.