# Apply multiplication to all elements in an array

7 messages
Open this post in threaded view
|

## Apply multiplication to all elements in an array

 Hi there, I'm new to coding and can someone guide or direct me to how I can multiply a constant (say 5) to an array of elements: For e.g. a = newArray(0,1,2,3,4); I wish to get another array whereby: b = 0, 5, 10, 15, 20 Thanks. WJ -- Sent from: http://imagej.1557.x6.nabble.com/-- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Open this post in threaded view
|

## Re: Apply multiplication to all elements in an array

 Dear WJ, Try a = newArray(0,1,2,3,4); b = newArray(5); for (i=0; i
Open this post in threaded view
|

## Re: Apply multiplication to all elements in an array

 Dear Kees and WJ, I'm sorry to disturb, but I would rather do it this way: a = newArray(0,1,2,3,4); for (i=0; i
Open this post in threaded view
|

## Re: Apply multiplication to all elements in an array

 In reply to this post by Straatman, Kees (Dr.) Hi Kees, The code works but I don't get why you need to have b = newArray(5)? Do you mind elaborating more on that? Thanks. Adam -- Sent from: http://imagej.1557.x6.nabble.com/-- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Open this post in threaded view
|

## Re: Apply multiplication to all elements in an array

 In reply to this post by Philippe CARL Hi Philippe, Thanks for your reply. Do you mind explaining what *= does? WJ -- Sent from: http://imagej.1557.x6.nabble.com/-- ImageJ mailing list: http://imagej.nih.gov/ij/list.html