简体   繁体   中英

Too many input arguments, even with varargin

Unfortunately I am getting a "Too many input arguments." error from performing this call:

[varargout{1:nargout}]=pca(varargin{1},'Algorithm','svd','Economy',fEconomy);

on the function that has signature as follows:

function [coeff, score, latent, tsquared, explained, mu] = pca(x,varargin)

I am calling princomp in this way:

[pc,score,latent,tsquare] = princomp(data);

Any idea of what might be the cause? (the bug appears in princomp.m of the stats package)

Look at the output of,

which -all pca

The first item should be something ending in \\toolbox\\stats\\stats\\pca.m . My guess is that you have another pca.m somewhere on your path.

I think it is because you have in the path a similiar function as the matlab built-in function: use this command to clear your path and try again.

userpath('clear')

note that this command will remove all the libraries you have added into the matlab path.

This can also happen for class methods that are defined outside of the classdef file (in a class folder), but that do have their method signature defined in the classdef file (see Methods in Separate Files ). If the function definition has the varargin argument, but the method signature in the classdef file doesn't, then you'll get this error when you try to pass in arguments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM