how can i vectorize this loop?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Miguel Reina
el 21 de En. de 2018
Respondida: Matt J
el 22 de En. de 2018
K=100;
a=zeros(K,1);
for u = 0:K-1
for b = 0:K-1
a(u+1) = a(u+1) + s(b+1)*exp((-2j*pi*u*b/K));
end
end
2 comentarios
Respuesta aceptada
Más respuestas (2)
Image Analyst
el 21 de En. de 2018
Well you could try meshgrid() but I think it might make it a little more confusing to understand what it's doing. With only 100x100 array to fill, a double for loop will be very fast so even if you did vectorize it, don't expect to notice any speed difference.
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!