How do I remove individual columns from each cell in cell array?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
lil brain
el 27 de Feb. de 2022
Respondida: Voss
el 27 de Feb. de 2022
Hi,
I have this cell array "baskets_data" where each cell contains a matrix that is 21 columns long.
baskets_data =
19×1 cell array
{1617×21 cell}
...
For every cell in this cell array, I want to select 9 pre-specified columns and leave out the rest. Namely, 1-3, 8-10 and 15-17.
I have written this code:
for i = 1:length(baskets_data)
baskets_xyz = baskets_data{i}(:,[1:3,8:10,15:17]);
end
But as a result I only get a baskets_xyz = 979×9 cell array.
How can I get the cell array to look as follows:
baskets_xyz =
19×1 cell array
{1617×9 cell}
...
Thank you!
0 comentarios
Respuesta aceptada
Voss
el 27 de Feb. de 2022
load('baskets_data.mat');
disp(baskets_data);
baskets_xyz = cell(size(baskets_data));
for i = 1:numel(baskets_data)
baskets_xyz{i} = baskets_data{i}(:,[1:3,8:10,15:17]);
end
disp(baskets_xyz);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!