expanding matrix
    8 views (last 30 days)
  
       Show older comments
    
Hi all
I want to expand matrix.for example if x=[x1;x2] then the new matrix will be:
xx = [x1 x1 x1;x1 x1 x2;x1 x2 x1;x1 x2 x2;x2 x1 x1;x2 x1 x2;x2 x2 x1;x2 x2 x2]
How can I do that
0 Comments
Accepted Answer
More Answers (1)
  Matt Fig
      
      
 on 16 May 2011
        Here is a general purpose file for doing the same thing. What you are basically doing is finding the permutations of the set [x1 x2] taken three at a time with replacement. For example:
x1 = 7;x2 = 9;  % Sample data
xx = npermutek([x1 x2],3);
xx =
       7     7     7
       7     7     9
       7     9     7
       7     9     9
       9     7     7
       9     7     9
       9     9     7
       9     9     9
0 Comments
See Also
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!

