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

5 visualizaciones (últimos 30 días)
Sourav Anilkumar
Sourav Anilkumar el 5 de Sept. de 2021
Editada: DGM el 6 de Sept. de 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
length(onset);
disp(['Onset Times = ', num2str(length(onset)),])
length(offset);
disp(['Offset Times = ', num2str(length(offset)),])

Respuestas (1)

DGM
DGM el 6 de Sept. de 2021
Editada: DGM el 6 de Sept. de 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.

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by