Not enough input arguments, when inputs are specified

Hovestar

This feels like a really dumb question because the error message is really straight forward, so I took a while to create as simple of a complete example as I could. It seems like when a constructor is called in a constructor ( I think I first noticed in a normal method not a constructor) and the objects are being put into an array in reverse order then matlab will give a not enough input arguments error for example:

classdef practice
    methods
        function self = practice(b)
            b
            if b>1
                for i = 2:-1:1
                    s(i) = practice(b-i);
                end
            end
        end
    end
end

called as

practice(4)

gives

b =

     4


b =

     2


b =

     0

Error using practice (line 4)
Not enough input arguments.

Error in practice (line 7)
                    s(i) = practice(b-i);

Error in practice (line 7)
                    s(i) = practice(b-i);

This case is odd because it only fails when getting to where b <= 1, but my real code doesn't fail like this. Any ideas on what exactly is going wrong and how I can fix it?

Justin

I think the problem is on the first iteration, when b = 4, you set s(i) = practice(b-i) and i = 2. This will initialize s to an array of practice of length 2, but since you initialize the second element first, the first element will get initialized to a default practice, where input b is undefined.

If you change the indices over i iterates to i = 1:2 this should fix the problem.

Edit:

For example, try clearing your workspace and then doing:

s(2) = practice(0)

This will attempt to assign practice(0) to s(2) and then s(1) will get assigned a default initialized practice, in which case b is not defined. This will replicate the problem you're having. The solution is to assign to s(1) first, and then s(2) next.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Not enough input arguments, when inputs are specified

From Dev

not enough input arguments fminsearch

From Dev

MATLAB - Not Enough Input Arguments

From Dev

MATLAB: Not enough input arguments in constructor when creating object array

From Dev

matlab Not enough input arguments error

From Dev

Not enough input arguments Inheritance Matlab

From Dev

Not enough input arguments in function Matlab

From Dev

Not enough input arguments error in matlab

From Dev

Not enough input arguments Inheritance Matlab

From Dev

MATLAB: "Not enough input arguments" error

From Dev

Not enough arguments when redefining a subroutine

From Dev

rectifyStereoImages throwing "Not enough input arguments error"

From Dev

python sql query stating 'not enough input arguments'

From Dev

rectifyStereoImages throwing "Not enough input arguments error"

From Dev

Error using plot. Not enough input arguments

From Dev

python sql query stating 'not enough input arguments'

From Dev

Is filter_input-regexp enough for inputs with "little freedom" ?

From Dev

Is filter_input-regexp enough for inputs with "little freedom" ?

From Dev

What will printf do when not enough arguments are passed?

From Dev

Calling function and getting - not enough input arguments, even though syntax is correct

From Dev

Unable to find why error "Not enough input arguments", Matlab

From Dev

Two functions in Matlab to approximate integral - not enough input arguments?

From Dev

Go to previous user input is user inputs specified string

From Dev

Will process be allocated enough heap when no explicit parameters are specified?

From Dev

Prediction in Caffe - Exception: Input blob arguments do not match net inputs

From Dev

TypeError: not enough arguments for format string when using %s

From Dev

Why aren't there enough inputs?

From Dev

Bisection Method: Not enough inputs error

From Java

Ctypes arguments called with not enough arguments

Related Related

  1. 1

    Not enough input arguments, when inputs are specified

  2. 2

    not enough input arguments fminsearch

  3. 3

    MATLAB - Not Enough Input Arguments

  4. 4

    MATLAB: Not enough input arguments in constructor when creating object array

  5. 5

    matlab Not enough input arguments error

  6. 6

    Not enough input arguments Inheritance Matlab

  7. 7

    Not enough input arguments in function Matlab

  8. 8

    Not enough input arguments error in matlab

  9. 9

    Not enough input arguments Inheritance Matlab

  10. 10

    MATLAB: "Not enough input arguments" error

  11. 11

    Not enough arguments when redefining a subroutine

  12. 12

    rectifyStereoImages throwing "Not enough input arguments error"

  13. 13

    python sql query stating 'not enough input arguments'

  14. 14

    rectifyStereoImages throwing "Not enough input arguments error"

  15. 15

    Error using plot. Not enough input arguments

  16. 16

    python sql query stating 'not enough input arguments'

  17. 17

    Is filter_input-regexp enough for inputs with "little freedom" ?

  18. 18

    Is filter_input-regexp enough for inputs with "little freedom" ?

  19. 19

    What will printf do when not enough arguments are passed?

  20. 20

    Calling function and getting - not enough input arguments, even though syntax is correct

  21. 21

    Unable to find why error "Not enough input arguments", Matlab

  22. 22

    Two functions in Matlab to approximate integral - not enough input arguments?

  23. 23

    Go to previous user input is user inputs specified string

  24. 24

    Will process be allocated enough heap when no explicit parameters are specified?

  25. 25

    Prediction in Caffe - Exception: Input blob arguments do not match net inputs

  26. 26

    TypeError: not enough arguments for format string when using %s

  27. 27

    Why aren't there enough inputs?

  28. 28

    Bisection Method: Not enough inputs error

  29. 29

    Ctypes arguments called with not enough arguments

HotTag

Archive