필터 지우기
필터 지우기

How do I run PCA on multiple cell arrays

조회 수: 3 (최근 30일)
lil brain
lil brain 2022년 4월 13일
댓글: lil brain 2022년 4월 13일
Hi,
I have a cell array (see attachment) where each cell contains an array with 21 columns (variables). Each cell represents a different participants and is of different length. I would like to run the PCA on each cell in the cell array and collect the outputs (coeff,score,latent,tsquared,explained,mu) for all participants.
The fucntion I want to use is the following with X being my cell array pre_data_1.
[coeff,score,latent,tsquared,explained,mu] = pca(X)
I am specifically interested in getting an "explained" that contains all the explained variables from each participant. In this variable each column should correspond to an explained variable from a cell/ participant.
I wonder if someone could help me with that?

채택된 답변

Image Analyst
Image Analyst 2022년 4월 13일
Did you try something like
numCells = numel(X);
for k = 1 : numCells
% Extract contents of cell into array.
thisX = X{k};
% Do PCA and store results in more cell arrays.
[coeff{k},score{k},latent{k},tsquared{k},explained{k},mu{k}] = pca(thisX);
end
It's untested on your data. It's just off the top of my head.
  댓글 수: 5
Image Analyst
Image Analyst 2022년 4월 13일
So did my answer work then?
lil brain
lil brain 2022년 4월 13일
yes :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by