How to create a 3d matrix as I want?
Show older comments
I want to create a 3d matrix with length*width*height
For width and height, I want both 4.
For length, [0,1,2,3], so length is 4. Overall, it is a 4*4*4 3d matrix.
I want to repeat [0,1,2,3] along the length/in the plane of width and height, so all 0 in length[1], all 1 in length[2], all 2 in length[3], all 3 in length[4]
Is there a simple method to create such 3d matrix?
Answers (1)
Ameer Hamza
on 1 May 2018
It is difficult to understand what do you mean by length, width, and height. But one way to create such a matrix is this
ones(4,4).*reshape(0:3, 1, 1, [])
All elements in one plane are same while moving along different planes, the value increase by one.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!