Can these operations be vectorized?

6 ビュー (過去 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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by