ERROR: Not enough input arguments.

1 view (last 30 days)
When I call my function, I get this error:
% Not enough input arguments.
% Error in CalcMKJointProb (line 26)
% for row = 1:obsData %loop through rows
However, if I copy & paste everything in my function (besides the function statement, of course) into the command window, it executes correctly and gets the result I want. I am not sure why this is or how to fix it.

Accepted Answer

Star Strider
Star Strider on 25 Sep 2020
That error could be thrown if ‘obsData’ is a variable that should be passed to your ‘CalcMKJointProb’ function as an argument, and is not. This could be the case if you attempt to run your function by clicking on the green Run triangle in the MATLAB Editor, rather than calling it from a script with the appropriate inputs.
The only other explanation for that error that occurs to me is that ‘obsData’ is a function that requires inputs and then returns something that your for loop uses to determine the number of iterations for ‘row’. If so, you need to call it with the appropriate arguments.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!