Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Multiplying an array by the individual elements of a vector

$
0
0

@samantp wrote:

So, I have an array, seed_dvh, and a vector, dvh_coeff, corresponding to some coefficients I’d like to multiply seed_dvh by. seed_dvh is of size 1718x2 and dvh_coeff is of length 1000.

I want to create a 1000 element vector of arrays, dvh_list, that consists of seed_dvh multiplied by the numbers in dvh_coeff
i.e. such that

dvh_list[1]=seed_dvh*dvh_coeff[1]
dvh_list[2]=seed_dvh*dvh_coeff[2]
dvh_list[3]=seed_dvh*dvh_coeff[3]

etc.

but I am not quite sure how to do this. I have tried dvh_list=dvh_coeff.*seed_dvh but of course this won’t work because the array sizes don’t match so pointwise multiplication is not possible.

Is there a way to do this without writing a for loop?
thanks.

Posts: 5

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles