How can I convert 2D matrix into a sequence?

5 vues (au cours des 30 derniers jours)
Rab Nawaz
Rab Nawaz le 30 Nov 2022
Réponse apportée : Purvaja le 12 Juin 2025
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 commentaires
Jonas
Jonas le 30 Nov 2022
for PCA reconstruction, look into here. Also have a look into the answer's comments
Rab Nawaz
Rab Nawaz le 30 Nov 2022
Modifié(e) : Rab Nawaz le 30 Nov 2022
@Jonas, Thanks for your comments, I check it out.

Connectez-vous pour commenter.

Réponses (1)

Purvaja
Purvaja le 12 Juin 2025
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!

Catégories

En savoir plus sur Dimensionality Reduction and Feature Extraction dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by