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 Exchange에서 Loops 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