Filter löschen
Filter löschen

Remove columns for a cell array

67 Ansichten (letzte 30 Tage)
Joseph Lee
Joseph Lee am 11 Dez. 2017
Beantwortet: Hedayat am 28 Nov. 2019
Z= {10x3000}
how do i trim away 1000 columns to
Z={10x2000}

Akzeptierte Antwort

per isakson
per isakson am 11 Dez. 2017
Bearbeitet: per isakson am 11 Dez. 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

Weitere Antworten (2)

James Tursa
James Tursa am 11 Dez. 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

Hedayat
Hedayat am 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}

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by