简体   繁体   中英

Not enough input arguments for xdot

I'm constantly getting the following error of not enough input arguments for my code as follows. Error occurs at xdot(1,1) line. This script is a function of the main script. What should I do to rectify this?

function xdot = ILS_Mdl(x,Psi_c)

global Ta Ka Tau g Vt Kr Kv Kd 

xdot(1,1) = x(2);

That error is quite clear. That means that you are trying to run the function without any input arguments. My guess is that you are trying to run this code by pushing the Play button in your editor. Don't do that... for the love of all that is MATLAB and holy... please don't do that. Ignore that play button for the rest of your time as a MATLAB developer. The play button essentially tries to run your script with no input parameters, and hence that's why you're getting that error.

The only time I would consider pushing the Play button is if your file is just a script file... and in that case... then that's ok... but ixnay on the Play button for function script files.

Actually run the function in the command prompt, or call it from whichever script is trying to run that code. Therefore, either go into your MATLAB command prompt or go inside your script and actually type this in:

xdot = ILS_Mdl(x,Psi_c);

Make sure x and Psi_c defined first before running the above code, so it's really:

%// Define x, and Psi_c here
x = [1 2 3];
Psi_c = 4;

xdot = ILS_Mdl(x, Psi_c);

xdot should contain a 5 element vector that computes your expected result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM