Effacer les filtres
Effacer les filtres

Remove columns for a cell array

67 vues (au cours des 30 derniers jours)
Joseph Lee
Joseph Lee le 11 Déc 2017
Z= {10x3000}
how do i trim away 1000 columns to
Z={10x2000}

Réponse acceptée

per isakson
per isakson le 11 Déc 2017
Modifié(e) : per isakson le 11 Déc 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

Plus de réponses (2)

James Tursa
James Tursa le 11 Déc 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 le 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}

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by