reduce time taken to execute nested for loop
Afficher commentaires plus anciens
Hi,
I am trying to subtract two matrix. and my program is as follows :
for i=1:length(B)
for j=1:length(A)
Y(j,:)=B(i,:)-A(j,:); %(takes one row of B and subtracts it with each row of A)
end
end
Now the inner for loop takes about 0.37 seconds. But my matrices are huge A[7000,100] & B[4000,1000]. Hence the above nested for loop takes about half hour+ to execute completely. Can anyone please suggest a much faster way to do the same. (hopefully in a minute or two)
1 commentaire
krs.rb1
le 17 Oct 2011
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!