Vectorization of nested for loop
Mostra commenti meno recenti
Hello !
I am trying to vectorize this nested for loop but I cannot think of any solution.
L=zeros(4,200,3);
for i=1:3
for p=4:200
for q=1:4
L(q,p,i)=G(p-q+1,i);
end
end
end
What I tried (but doesnt work) :
L = zeros(4,200,3);
[p,q] = ndgrid([4:200],[1:4]);
p = p(:);
q = q(:);
L(q,p,:)=G(p-q+1,:);
Can someone please help me with what is wrong with my logic ?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements 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!