Reshape and Repmat neatly

Hi,
Can anyone help me Reshape and Replicate columns efficiently in MATLAB, I can do it with reshape and repmat but is extremely messy and i'm sure theres a quicker and neater way.
e.g.
A = [ a b c 1 2 3 4 5 6 7 8 9; d e f 1 2 3 4 5 6 7 8 9 ]
to
B = [ a b c 1 2 3; a b c 4 5 6; a b c 7 8 9; d e f 1 2 3; d e f 4 5 6; d e f 7 8 9; ]
Thanks

2 Comments

Numbers and letters cannot be mixed in a numeric array.
Jan
Jan on 15 Mar 2012
@Simon: It would easier to create an answer, if you use a numeric matrix with unqiue values.

Sign in to comment.

Answers (1)

Sean de Wolski
Sean de Wolski on 15 Mar 2012

1 vote

What is wrong with reshape and repmat? Reshape is extremely fast and some form of repmat is necessary since you want that much data at the end, i.e. you're not saving memory by avoiding rempat.

2 Comments

Jan
Jan on 15 Mar 2012
Instead of REPMAT a ONES as index can be used. But this happens inside REPMAT also.
Geoff
Geoff on 15 Mar 2012
Simon, if you are concerned about your solution being messy, why don't you post it? The community might be able to suggest a way to make it tidier.

Sign in to comment.

Tags

Asked:

on 15 Mar 2012

Community Treasure Hunt

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

Start Hunting!