Can these operations be vectorized?

1 view (last 30 days)
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 Comment
Matt Fig
Matt Fig on 15 Oct 2012
Why did you use the Code button on your paragraph, but not on the code?? Please fix this.

Sign in to comment.

Accepted Answer

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

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!