Given a vector v = [1 2 3 4 5 6] how do I turn it into:
v =
v(:,:,1) = 1
v(:,:,2) = 2
v(:,:,3) = 3
v(:,:,4) = 4
v(:,:,5) = 5
v(:,:,6) = 6
i.e., transpose between the second (row) and third dimension?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The answer is to use the permute command:
It accepts non-existing dimensions: the second argument specifies swapping the first existing dimension with the third existing dimension (none), which creates a ‘singleton’ first dimension in the result.