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

조회 수: 4 (최근 30일)
lil brain
lil brain 2022년 3월 24일
답변: Arif Hoq 2022년 3월 24일
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!

채택된 답변

Arif Hoq
Arif Hoq 2022년 3월 24일
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....

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by