NimrodB
NimrodB

Reputation: 153

How to increase a cell array size?

I have a cell array with the dimensions of: 1x11x2

I want to increase it to 3x11x2 by adding a row of ' '

How do I do that?

For ex.: Array A:

a(:,:,1) = 

    'Value3'    ''    ''    'Value1'    ''    ''    ''    ''    ''    ''    ''


a(:,:,2) = 

    ''    ''    ''    ''    'Error'    ''    ''    ''    ''    ''    ''

And I want it to be:

a(:,:,1) = 

    'Value3'    ''    ''    'Value1'    ''    ''    ''    ''    ''    ''    ''
    ''    ''    ''    ''    ''    ''    ''    ''    ''    ''    ''

a(:,:,2) = 

    ''    ''    ''    ''    'Error'    ''    ''    ''    ''    ''    ''
    ''    ''    ''    ''    ''    ''    ''    ''    ''    ''    ''

Upvotes: 2

Views: 2671

Answers (2)

Dennis Jaheruddin
Dennis Jaheruddin

Reputation: 21561

Only a partial answer, but this should allow you to easily get the right amount of empty strings:

regexprep(a(:,:,1),'.','')

Upvotes: 0

reverse_engineer
reverse_engineer

Reputation: 4269

The most generic code would be:

a = [a; reshape(repmat({''},1,size(a,2)*size(a,3)),1,size(a,2),size(a,3))];

Hope this helps...

Upvotes: 2

Related Questions