how to run principal component analysis in a 3D matrix

조회 수: 58 (최근 30일)
Hugo
Hugo 2022년 2월 21일
답변: Image Analyst 2022년 2월 22일
Hi,
I am trying to run principal component analysis, pca() function to a 3D matrix. It does not work and I think it only works with 2D matrixes. Is there any way to circunvent this limitation?
Thank you,
Best regards,

채택된 답변

AndresVar
AndresVar 2022년 2월 21일
편집: AndresVar 2022년 2월 21일
You can reshape the matrix to 2D and then when you get results convert it back to the orginal dimensions if needed
There tricky part is to choose how to reshape. But say 2 dimensions are data, and the third is time then
data3d = ones([2,2,3]);
data2d = reshape(data3d,[],size(data3d,3));
size(data2d)
ans = 1×2
4 3
so the columns become the new time dimension.

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 2월 22일
See my attached demo where I run it on a 3-D (true color) image. Adapt as needed.

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by