Delete cell array column

Placed simple values ​​in an array of cells for testing.

model{1,1}=1;model{1,2}=2;model{1,3}=3;
model{2,1}=4;model{2,2}=5;model{2,3}=6;
i=2;//I want to remove the second column

temp={  model{:,1:i-1} model{:,i+1:size(model,2)}  }

I need the result:

temp =

[1]    [3]    
[4]    [6]

But I get this:

temp =

[1]    [4]    [3]    [6]

How can I get this right?

ps: for those who work in Cell Arrays, there is a good technique to add here .

+3
source share
3 answers

You can change or delete the cells themselves using () -addressing.

model(:,2) = [];
+10
source

You have to move two parts and change some parentheses:

temp= [{ model{:,1:i-1}}' {model{:,i+1:size(model,2)}}']
+1
source

there is a fun_removecellrowcols function that removes specific rows / columns specified by the user. This affects the size of the cell, due to the removal of the row / column.

http://www.mathworks.com/matlabcentral/fileexchange/46196-fun-removecellrowcols

Regards, Jose

+1
source

All Articles