Vectorization for dependent loops

1 visualización (últimos 30 días)
Damiano Capocci
Damiano Capocci el 6 de En. de 2018
Editada: Damiano Capocci el 6 de En. de 2018
Hi i want vectorize this code :
a(1)= 1 ;
for g=1:len_1 % len_1 >> len_2
for c=0:min(g-1,len_2) % the use of min() is related to the positive sign of index g-c
a(g+1)=a(g+1)+k(c+1)*k(g-c)
end
end
in the same way as this situation:
k=zeros([1,10000]);
for i=1:10000;
k(i)=rand;
end
k=zeros([1,10000]);
a=1:10000;
k(a)=rand;
Any idea?

Respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by