how to expand cell array?

I have a cell array that contains T1-001, T2-001, T1-002, T2-002....T2-058. I am trying to expand the cell array 368x but I would like to keep them together (T1-001 with T2-002 and etc. How do I expand it so that T1-001 and T2-001 expands 368x .

2 Comments

dpb
dpb on 24 Oct 2013
I don't follow...how about posting a small example w/ a much smaller expansion factor and showing input/desired output?
for example:
  • T1-001
  • T1-001
  • T1-001
  • T2-001
  • T2-001
  • T2-001
  • T1-002
  • T1-002
  • T1-002
  • T2-002
  • T2-002
  • T2-002etc

Sign in to comment.

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 24 Oct 2013
Edited: Azzi Abdelmalek on 24 Oct 2013
a=[sprintf('T1-00%d T2-00%d ',[1:9;1:9]) sprintf('T1-0%d T2-0%d ',[10:58;10:58]) ]
out=regexp(a,'\w+\-\w+','match')
out=reshape(repmat(out,368,1),[],1)
%or
a=sprintf('T1-%3d*T2-%3d*',[1:58;1:58])
b=regexp(a,'[^\*]\w+\-\s+\w+','match')
out=strrep(b,' ','0')
out=reshape(repmat(out,368,1),[],1)

6 Comments

I was wondering how can I get it to print out every 368, so for example T1-001 and t2-002 print a total of 368 and so on.
Azzi Abdelmalek
Azzi Abdelmalek on 25 Oct 2013
Edited: Azzi Abdelmalek on 25 Oct 2013
That's what the above code do
how can I make it that T1-001 and T2-001 are in the same cell example:
  • T1-001,T2-001
  • T1-002,T2-002
a=sprintf('T1-%3d*T2-%3d*',[1:58;1:58])
b=regexp(a,'[^\*]\w+\-\s+\w+','match')
out=strrep(b,' ','0')
out=reshape(out,2,[])'
how do I merge the 2 columns so that it is 'T1-001, T2-001', etc
a=sprintf('T1-%3d*T2-%3d*',[1:58;1:58])
b=regexp(a,'[^\*]\w+\-\s+\w+','match')
out=strrep(b,' ','0')
out=reshape(out,2,[])'
res=cellfun(@(x,y) [x ', ' y],out(:,1),out(:,2),'un',0)

Sign in to comment.

idx = ndgrid(1:length(YourArray), ones(1,368));
NewArray = YourArray(idx);

Tags

Asked:

on 24 Oct 2013

Commented:

on 14 Nov 2013

Community Treasure Hunt

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

Start Hunting!