How can i make my code run faster
Show older comments
Hi.
Is there a better way of writing a nested loop? My code Works well but it takes about 7min to completely execute.
for i=1:Z
n = 0;
for j=1:N
for k=1:M
if (Distance_Unique(i)==Distance(j,k))
n = n+1;
Residual_Sqrd(n) = Residual_Squared(j,k);
Summation_Residual_Squared(i) = sum(Residual_Sqrd);
end
end
end
Residual_Sqrd = zeros();
end
Thanks in advance. Darl.
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!