A=[1; 2; 3];
B=[4, 5, 6];
for k = 1:20
c(:,:,k) = A;
d(:,:,k) = B;
end
I want to calculate values of c(:,:,k) and d(:,:,k) without loop.

 採用された回答

Geoff Hayes
Geoff Hayes 2015 年 11 月 1 日

0 投票

Ranjan - try using repmat to repeat the copies of your arrays. Your above code should then reduce to
C = repmat(A,1,1,20);
D = repmat(B,1,1,20);

その他の回答 (0 件)

カテゴリ

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

製品

質問済み:

2015 年 11 月 1 日

回答済み:

2015 年 11 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by