I'm getting an error when I was using compute_mapping function for pca, please give me any suggestions how can I solve it?

조회 수: 3 (최근 30일)
Error using internal.stats.parseArgs (line 42)
Wrong number of arguments.
Error in pca (line 174)
= internal.stats.parseArgs(paramNames, defaults, varargin{:});
Error in compute_mapping (line 309)
if isempty(varargin), [mappedA, mapping] = pca(A, no_dims);
Error in run_feature (line 34)
[P_A_feature, mapping1] = compute_mapping(P_A_feature, 'PCA', 28); //this is the code i wrote

답변 (1개)

Aditya
Aditya 2025년 2월 4일
Hi Bhawna,
The error message you're encountering suggests that there's an issue with the number of arguments being passed to a function, likely the pca function. In your case, it seems to be related to how compute_mapping is calling pca.
To troubleshoot and resolve this issue, let's go through a few steps:
  1. Verify compute_mapping Implementation: Ensure that the compute_mapping function is correctly implemented to handle PCA. It should call the pca function with the correct number of arguments. Here's a simplified example of how compute_mapping might handle PCA:
function [mappedA, mapping] = compute_mapping(A, method, no_dims)
if strcmpi(method, 'PCA')
[coeff, score, latent, tsquared, explained, mu] = pca(A, 'NumComponents', no_dims);
mappedA = score; % The transformed data
mapping.coeff = coeff;
mapping.latent = latent;
mapping.explained = explained;
mapping.mu = mu;
else
error('Unknown method.');
end
end
2. Arguments for pca: The pca function in MATLAB can take additional parameters, such as 'NumComponents', to specify the number of principal components. Make sure these parameters are correctly passed.

카테고리

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