How can I convert 2D matrix into a sequence?

조회 수: 7 (최근 30일)
Rab Nawaz
Rab Nawaz 2022년 11월 30일
답변: Purvaja 2025년 6월 12일
I need to convert a matrix into a sequence. I have performed PCA on it and obtained 6 principle components. The PC1 contains almost 51 percent information. PC1 and PC2 contains 99% information. Is there any way that I can use PC1 and PC2 as a sequence in a sequence classifier or generate a sequence from above mentioned matrix. Anyone can give any hint or idea please.
  댓글 수: 2
Jonas
Jonas 2022년 11월 30일
for PCA reconstruction, look into here. Also have a look into the answer's comments
Rab Nawaz
Rab Nawaz 2022년 11월 30일
편집: Rab Nawaz 2022년 11월 30일
@Jonas, Thanks for your comments, I check it out.

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

답변 (1개)

Purvaja
Purvaja 2025년 6월 12일
Assuming the data to be time series or sequential data, we can depict the matrix data as sequence data as follows:
Using the 1800x2 PCA Matrix (from Principal components PC1 and PC2)
1.Treat each row (i.e. one time step of PC1 and PC2) as an input to your sequence model:
% Example PCA data
PCA_data = rand(1800, 2); % Dummy data
% Convert to sequence: each row becomes a 1×2 sequence
sequenceData = mat2cell(PCA_data, ones(1800, 1), 2);
Output: a 1800×1 cell array, each cell is a 1×2 vector like [PC1, PC2].
You now have a proper input format for sequence models, where each time step is a feature vector [PC1, PC2]
2. Add labels as necessary (for classification).
labels = categorical(randi([1, 2], 1800, 1)); % Dummy binary labels
3.Train on any sequence classifier like LSTM.
For more clarifications refer to the following official MathWorks documentation links:
  1. PCA: https://www.mathworks.com/help/stats/pca.html
  2. Sequence classification using deep learning: https://www.mathworks.com/help/deeplearning/ug/classify-sequence-data-using-lstm-networks.html
Hope this helps you!

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by