Effacer les filtres
Effacer les filtres

Can these operations be vectorized?

3 vues (au cours des 30 derniers jours)
Vinod S
Vinod S le 15 Oct 2012
X=1:100;
T=zeros(10);
for i=1:10
T(i,:)=X((1+(i-1)*10):(10*i));
end
Please tell me how to do these operations without using the FOR Loop.
  1 commentaire
Matt Fig
Matt Fig le 15 Oct 2012
Why did you use the Code button on your paragraph, but not on the code?? Please fix this.

Connectez-vous pour commenter.

Réponse acceptée

Matt Fig
Matt Fig le 15 Oct 2012
T = reshape(1:100,10,10).'
  3 commentaires
Matt Fig
Matt Fig le 15 Oct 2012
Give it a try! Did you notice that I took the transpose?
Vinod S
Vinod S le 16 Oct 2012
Yes sir, it does work. Thanks.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by