creating multi-dimensional arrays from vectors
Show older comments
Hi,
I want to create a multi-dimensional array 'b' from a vector 'a' as the following example:
a =
1 2 3 4
b(:,:,1) =
1 1
1 1
b(:,:,2) =
2 2
2 2
b(:,:,3) =
3 3
3 3
b(:,:,4) =
4 4
4 4
Thus I want to copy each entry of 'a' as m by n (2 by 2 in the example) size matrices onto each level of 'b' along the third dimension. I need to avoid element-wise operations and be as fast as possible.
I would appreciate any help.
Thank you.
Accepted Answer
More Answers (1)
James Tursa
on 27 Mar 2012
1 vote
You can also see this related discussion:
Categories
Find more on Resizing and Reshaping Matrices 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!