Reputation: 49
I have a cell array with different cells.
val{1}=[1 2 3 4]
val{2}=[5 6 7 8 9 10]
val{3}=[11 12 13]
val{4}=[14 15 16 17 18 19 20]
Now I want to cut every cell that I have left 2 elements:
val{1}=[1 2]
val{2}=[5 6]
val{3}=[11 12]
val{4}=[14 15]
Thanks in advance.
Upvotes: 2
Views: 243
Reputation: 3898
Try this:
val = cellfun(@(x) [x(1), x(2)],val,'UniformOutput',false);
Upvotes: 2