How to remove only a range of cells in a column in matlab

I have a 23x5 cell array and I am trying to replace all the cells but first a blank cell in one column.

When I try array{2:end,4}=[]

, I get "The right side of this assignment has too few values ​​to satisfy the left side."

Still confused about how Matlab handles different classes, I also tried array(2:end,4)=[]

and get "Null assignment can only have one index without a colon".

I know that a for loop can easily clear the contents of each cell, but I feel like it should be easier to solve this.

Thanks for the help.

+3


source to share


1 answer


Try using:

array(2:end,4) = {[]}



For example:

>> array = cell(23,5);
>> array(:) = {1};
>> array(2:end,4) = {[]}
array = 

    [1]    [1]    [1]    [1]    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]
    [1]    [1]    [1]     []    [1]

      

+6


source







All Articles