Remove columns for a cell array
56 views (last 30 days)
Show older comments
Z= {10x3000}
how do i trim away 1000 columns to
Z={10x2000}
0 Comments
Accepted Answer
per isakson
on 11 Dec 2017
Edited: per isakson
on 11 Dec 2017
One way
>> cac = cell(10,3000);
>> cac = cac(:,1:end-1000);
>> size(cac)
ans =
10 2000
>>
and another
cac = cell(10,3000);
cac(:,2001:end) = [];
whos cac
Name Size Bytes Class Attributes
cac 10x2000 160000 cell
0 Comments
More Answers (2)
James Tursa
on 11 Dec 2017
Not sure what Z really is from your description. Maybe one of these will work for you:
Z(:,2001:end) = []; % assumes Z is a cell array of size 10x3000
or maybe
Z{1}(:,2001:end) = []; % assumes Z is a single cell with a 10x3000 array inside of it
0 Comments
Hedayat
on 28 Nov 2019
If you want to delete more than one rows of cell you can ...
a= cell(5,5)
a =
5×5 cell array
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
a([2,3],:)=[]
a =
3×5 cell array
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
0 Comments
See Also
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!