How do I extract column vectors from a cell of doubles array?

5 vues (au cours des 30 derniers jours)
lil brain
lil brain le 24 Mar 2022
Hi,
I have the cell of doubles array "cell_of_doubles" with 19 columns (19 cells). I am looking to extract only the first three columns from each cell and save them seperately in a three column vector (not a cell array).
This way I would like to create 19 new variables each containing three columns.
How would I do that?
Thank you!

Réponse acceptée

Arif Hoq
Arif Hoq le 24 Mar 2022
A=load('cell_of_doubles.mat');
B=A.cell_of_double_balls ;
C=cell(size(B,2),1);
for i=1:size(B,2)
C{i}=B{1, i}(:,1:3); % first 3 columns from every cell
end
firstcell=C{1, 1}; % extract variable 1 by linear indexing
secondcell=C{2, 1}; % extract variable 2 by linear indexing and so on....

Plus de réponses (0)

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