create special matrix without use from for loop

i wish create several matrix with out uses from for loop
for example
j=1;
for i=2:2:(2*T)
a=zeros(1,2*T);
a(i-1)=1; a(i)=-1;
one(j,:)=a;
j=j+1;
end
that every time T Replaced different number

 採用された回答

Walter Roberson
Walter Roberson 2015 年 5 月 24 日

0 投票

For any given T,
a = zeros(T,2*T);
a(1:2*T+1:end) = 1;
a(T+1:2*T+1:end) = -1;

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2015 年 5 月 24 日

回答済み:

2015 年 5 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by