How can I run PCA on a 3-dimensional cell arrays?
2 views (last 30 days)
Show older comments
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.
This is what I have until now:
numCells = numel(pre_data1);
for k = 1 : numCells
for p = 1 : n
thisX = pre_data1{k}{p};
[coeff{k}{p},score{k}{p},latent{k}{p},tsquared{k}{p},explained{k}{p},mu{k}{p}] = pca(thisX);
end
end
But when I run this I only get strange results like so:
explained =
1×2 cell array
{1×1 cell} {1×1 cell}
I wonder if someone could help me with that?
0 Comments
Answers (0)
See Also
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!