Indexing of a temporary array.

1 view (last 30 days)
Vinod S
Vinod S on 20 Oct 2012
x=(meshgrid([1 2 3],[1 2 3]).*meshgrid([1 2 3],[1 2 3])')
x=x(:)'
Is it possible to carry out the above 2 operations in a single line code. Or in other works is there a way to go around the restriction in Matlab 'A temporary array cannot be indexed'.? Thanks in Advance.

Accepted Answer

Walter Roberson
Walter Roberson on 20 Oct 2012
x = reshape( (meshgrid([1 2 3],[1 2 3]).*meshgrid([1 2 3],[1 2 3])'), 1, []);

More Answers (1)

Matt J
Matt J on 20 Oct 2012
Edited: Matt J on 21 Oct 2012
x=kron(1:3,1:3);

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!