Allocating values in a 3D array using nested for loops
이전 댓글 표시
I've created a 3D array (A) of zeros with dimensions : A=zeros(3,2,4). Using nested for loops I need to overwrite their values so the first value on the first page is 24, and all other values reduce by one each time.
Ex:
A(:,:,1)
24 23
22 21
20 19
A(:,:,2)
18 17
16 15
14 13
Other than pre-allocating A I have no idea where to start, any help would be appreciated.
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2014년 10월 24일
A=permute(reshape(24:-1:1,2,3,4),[2 1 3])
댓글 수: 2
Blake Barrows
2014년 10월 24일
Azzi Abdelmalek
2014년 10월 24일
If it's a homework then try something yourself
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!