I'm struggling with something that seems like it should be very simple. I'm trying to create an array of 3×3 matrices. I see that I can do something like:
A = [1,2,3; 4,5,6; 7,8,9]A(:,:,2) = [9,8,7; 6,5,4; 3,2,1]
How do I do that in one line? I thought that something like this would work:
A = [[1,2,3; 4,5,6; 7,8,9]; [9,8,7; 6,5,4; 3,2,1]]
But that creates a 6×3 matrix. And this creates a 3×6 matrix:
A = [[1,2,3; 4,5,6; 7,8,9] [9,8,7; 6,5,4; 3,2,1]]
I've tried other variations and read documentation, but am at a loss here. Any help would be appreciated. Thanks!
Best Answer