필터 지우기
필터 지우기

Indexing vectors in a cell matrix with for loops?

조회 수: 2 (최근 30일)
Camille Godin
Camille Godin 2021년 6월 7일
댓글: Camille Godin 2021년 6월 7일
Hello,
I have a 1x8 cell matrix. Each cell contains a 30x500 matrix. I need to combine the 3 first row vectors in each cell to form a new matrix. The new matrix needs to have 8 columns, each column representing the original cell. That being said, the 3 original row vectors have to be combined in one column vector. My final matrix will be 1500x8.
Basically, I have no idea how to index vectors from each cell to form a new matrix.
Thank you in advance.

채택된 답변

SALAH ALRABEEI
SALAH ALRABEEI 2021년 6월 7일
if true
% You can either use this
A{1}(1:3,:) %to extract the first 3 rows of the 1st matrix, and the same for all.
% Or convet the cell to mat, then you know the rest
B = reshape(cell2mat(A),30,1500,8);

추가 답변 (1개)

David Hill
David Hill 2021년 6월 7일
newmat=zeros(1500,8)
for k=1:8
t=yourCell{k}(1:3,:);
t=t';
newmat(:,k)=t(:);
end

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by