fstab
fstab

Reputation: 5029

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)

Upvotes: 2

Views: 2689

Answers (3)

dkumpf
dkumpf

Reputation: 11

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.

Upvotes: 0

user2867655
user2867655

Reputation: 113

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.

Upvotes: 2

chappjc
chappjc

Reputation: 30579

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.

Upvotes: 6

Related Questions