How to speed up this loops?
Mostra commenti meno recenti
Hi,
Is there a way to speed up this?
maxN = 120;
x = -30:0.1:30;
xElements = numel(x);
u_mn = zeros(xElements, xElements);
for m = -maxN:2:maxN
for i = 1 : xElements
for j = 1 : xElements
u_mn(i, j) = sqrt((n+1)/pi) * besselj(m+1, 2*sqrt(x(i)^2 + x(j)^2)) / sqrt(x(i)^2 + x(j)^2)^(m+1) * (x(i) + 1i*x(j))^m;
end
end
end
Best regards, Alex
4 Commenti
CS Researcher
il 1 Giu 2016
Modificato: CS Researcher
il 1 Giu 2016
What is n here? Is there another loop for it?
Alex Kurek
il 1 Giu 2016
Walter Roberson
il 1 Giu 2016
You do not store the results for each different m, and you are not summing them or anything like that, so the effect is as if you had only done the final m value.
Alex Kurek
il 2 Giu 2016
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Operators and Elementary Operations in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!