Search code examples
arraysmatlabmatrixcelldimensions

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'    ''    ''    ''    ''    ''    ''
    ''    ''    ''    ''    ''    ''    ''    ''    ''    ''    ''

Solution

  • 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...