Effacer les filtres
Effacer les filtres

replacing a for loop

1 vue (au cours des 30 derniers jours)
Mnr
Mnr le 28 Nov 2015
Commenté : Mnr le 29 Nov 2015
Hello all,
I have a simple piece of code that I would like to get rid of the for loop. I would appreciate your help.
for n=1:K
idx=row((((n-1)*dc)+1):(n*dc));
end
where as an example K=4, dc=2, and row=[1;3;2;3;1;4;2;4];

Réponse acceptée

Walter Roberson
Walter Roberson le 28 Nov 2015
t = reshape(row, dc, []);
idx = t(:,1:K);
  1 commentaire
Mnr
Mnr le 29 Nov 2015
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by