Code generation for `sum` function in MATLAB In cross correlation we use the below command to calculate the sum after elementary multiplication of the vectors. But when we try to convert this Matlab code to vhdl using HDL coder, this command is not defined by HDL coder. Is it possible to write code for below line without using 'sum' builtin function please.

xc(i)=sum((y1(j1:k1)).*y2(j2:k2));


where j1, j2, k1 and k2 are the starting and ending limits.
y1 and y2 are two vectors and are being multiplied element wise and the result is being added.

Thanks
Because the size of y1(j1:k1) and y2(j2:k2) must be the same then:
$$
k_1-j_1 = k_2-j_2
$$
and you will also have something like: $j_1+N=j_2$ then you could write a for loop like this:

xc(i) = 0
for n=j1:k1
  xc(i) = xc(i) + y1(n)*y2(n+N)
end