create a vector ,of sets of predefined numbers stored in another row vectors
Show older comments
Guys,I have two row vectors X=[3:6] and Y=[8:27].I want to create and store all possible combinations of (X,Y) in another vector ,say Z.
So my Z will be, Z=[(3,8) (3,9) (3,10)...(3,27) (4,8) (4,9)......(6,26) (6,27)]
Accepted Answer
More Answers (1)
James Tursa
on 3 Mar 2015
Edited: James Tursa
on 3 Mar 2015
Not sure how you want the answer actually stored (the syntax in your example isn't clear), but here is one way:
XX = repmat(X(:)',numel(Y),1);
YY = repmat(Y(:),1,numel(X));
Z = [XX(:) YY(:)];
1 Comment
Ace_ventura
on 3 Mar 2015
Categories
Find more on Multidimensional Arrays 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!