how to resolve the error

4 views (last 30 days)
ajith
ajith on 13 Nov 2013
Edited: Walter Roberson on 3 Feb 2025 at 4:54
[pc,score,latent,tsquare] = princomp(x); red_dim = score(:,1:50);
??? Error using ==> svd Out of memory. Type HELP MEMORY for your options.
Error in ==> princomp at 85 [U,sigma,coeff] = svd(x0,econFlag); % put in 1/sqrt(n-1) later
MY x value consist 50x36033 i need to use feature reduction

Answers (1)

Aditya
Aditya on 3 Feb 2025 at 4:31
Hi Ajith,
The error you're encountering is due to memory limitations when trying to perform Singular Value Decomposition (SVD) on a large matrix using princomp. Since princomp is deprecated and you have a large dataset, it's better to use pca, which is more efficient and offers better handling of large datasets.
% Assume X is your data matrix with observations in rows and variables in columns
% In your case, X is 50x36033
% Perform PCA
[coeff, score, latent, tsquared, explained, mu] = pca(X, 'NumComponents', 50);
% score contains the reduced dimensions (50x50)
% coeff contains the principal component coefficients
% latent contains the eigenvalues
% tsquared contains Hotelling's T-squared statistic
% explained contains the percentage of total variance explained by each component
% mu contains the estimated mean of each variable
% Extract the reduced dimensions
red_dim = score; % This will be 50x50
% If you need to transform new data into the reduced space, use:
% new_data_transformed = (new_data - mu) * coeff(:, 1:50);
Using pca instead of princomp should help you perform PCA more efficiently on large datasets and reduce the dimensionality to the desired number of components.

Categories

Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!