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

4 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Arif Hoq
Arif Hoq il 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....

Più risposte (0)

Categorie

Scopri di più su Cell Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by