Can these operations be vectorized?

조회 수: 1 (최근 30일)
Vinod S
Vinod S 2012년 10월 15일
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
Matt Fig
Matt Fig 2012년 10월 15일
Why did you use the Code button on your paragraph, but not on the code?? Please fix this.

댓글을 달려면 로그인하십시오.

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by