Effacer les filtres
Effacer les filtres

How to fix "error using class. Not enough input arguments"?

7 vues (au cours des 30 derniers jours)
Sourav Anilkumar
Sourav Anilkumar le 5 Sep 2021
Modifié(e) : DGM le 6 Sep 2021
Wrote this function code as part of a worksheet. It was working normally but all of a sudden I am getting an error message. I didn't change anything so I have no clue how this happened?
% Find the time points corresponding to the onset and offset times from the classifier
[onset, offset] = change_times(class, time);
(error comes after the line above)
% Display the number of onset/offset times determined with each classifier
disp(['Onset Times = ', num2str(length(onset)),])
disp(['Offset Times = ', num2str(length(offset)),])

Réponses (1)

DGM le 6 Sep 2021
Modifié(e) : DGM le 6 Sep 2021
You had probably shadowed the function class() with some variable by the same name -- which is something you should avoid.
which class -all
built-in (/MATLAB/toolbox/matlab/datatypes/class) /MATLAB/toolbox/matlab/graph2d/@scribehandle/class.m % Shadowed scribehandle method /MATLAB/toolbox/instrument/instrument/@udp/class.m % Shadowed udp method /MATLAB/toolbox/instrument/instrument/@i2c/class.m % Shadowed i2c method /MATLAB/toolbox/instrument/instrument/@gpib/class.m % Shadowed gpib method /MATLAB/toolbox/instrument/instrument/@icdevice/class.m % Shadowed icdevice method /MATLAB/toolbox/instrument/instrument/@visa/class.m % Shadowed visa method /MATLAB/toolbox/instrument/instrument/@tcpip/class.m % Shadowed tcpip method /MATLAB/toolbox/instrument/instrument/@Bluetooth/class.m % Shadowed Bluetooth method /MATLAB/toolbox/instrument/instrument/@icgroup/class.m % Shadowed icgroup method /MATLAB/toolbox/matlab/serial/@serial/class.m % Shadowed serial method
help class
CLASS Return class name of object. S = CLASS(OBJ) returns the name of the class of object OBJ. Possibilities are: double -- Double precision floating point number array (this is the traditional MATLAB matrix or array) single -- Single precision floating point number array logical -- Logical array char -- Character array cell -- Cell array struct -- Structure array function_handle -- Function Handle int8 -- 8-bit signed integer array uint8 -- 8-bit unsigned integer array int16 -- 16-bit signed integer array uint16 -- 16-bit unsigned integer array int32 -- 32-bit signed integer array uint32 -- 32-bit unsigned integer array int64 -- 64-bit signed integer array uint64 -- 64-bit unsigned integer array <class_name> -- MATLAB class name for MATLAB objects <java_class> -- Java class name for java objects %Example 1: Obtain the name of the class of value pi name = class(pi); %Example 2: Obtain the full name of a package-based java class obj = java.lang.String('mystring'); class(obj) For classes created without a classdef statement (pre-MATLAB version 7.6 syntax), CLASS invoked within a constructor method creates an object of type 'class_name'. Constructor methods are functions saved in a file named <class_name>.m and placed in a directory named @<class_name>. Note that 'class_name' must be the second argument to CLASS. Uses of CLASS for this purpose are shown below. O = CLASS(S,'class_name') creates an object of class 'class_name' from the structure S. O = CLASS(S,'class_name',PARENT1,PARENT2,...) also inherits the methods and fields of the parent objects PARENT1, PARENT2, ... O = CLASS(struct([]),'class_name',PARENT1,PARENT2,...), specifying an empty structure S, creates an object that inherits the methods and fields from one or more parent classes, but does not have any additional fields beyond those inherited from the parents. See also ISA, CLASSDEF, STRUCT, SUPERIORTO, INFERIORTO. Documentation for class doc class Other functions named class Bluetooth/class icdevice/class serial/class udp/class gpib/class icgroup/class tcpip/class visa/class i2c/class scribehandle/class
Since said variable is now missing and not shown in the provided code excerpt, you'll have to figure out where it went.


En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by