Not enough input arguments

5 visualizzazioni (ultimi 30 giorni)
Anthony Santana
Anthony Santana il 3 Mar 2023
Risposto: Walter Roberson il 4 Mar 2023
I am a novice and I ran this code in December with no issues. Now I get an error "Not enough input arguments. Error in line 7. alg.ptag = pid;.
I was just prompted to renew my license, not sure if that changed my version to a new one that works differently.
How can I rewrite it so that it works? Did something change in Matlab?
function initalg(pid)
% Setting global parameters
global alg
alg = {};
% parameters to use
alg.ptag = pid;
  3 Commenti
Walter Roberson
Walter Roberson il 4 Mar 2023
it might be an attempt to clear the previous value of the the global since this is an initialization function. It should probably be something like
alg = struct() ;
Anthony Santana
Anthony Santana il 4 Mar 2023
Tried both, same result. Thanks though.
To be clear these are the very first lines of the very first file trying to initialize parameters for a simulated method of moments simulation. Its the very first lines of code.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 4 Mar 2023
The error message is telling you that you did one of three things:
  1. You invoked initalg or initalg() at the command line without providing any parameter for the function; OR
  2. You had code that called initalg() without passing in any parameter to the function; OR
  3. you were in the editor at initalg.m file and you pressed the green Run button. The Run button is equivalent to invoking the function without any parameters.

Più risposte (1)

Les Beckham
Les Beckham il 3 Mar 2023
Perhaps you have added the control system toolbox since last time this worked?
That toolbox contains a function named pid that expects input arguments.
which -all pid
/MATLAB/toolbox/control/ctrlmodels/@pid/pid.m % pid constructor /MATLAB/toolbox/control/ctrlmodels/@DynamicSystem/pid.m % DynamicSystem method /MATLAB/toolbox/shared/controllib/engine/@StaticModel/pid.m % StaticModel method
help pid
PID Create a PID controller in parallel form. Construction: SYS = PID(Kp,Ki,Kd,Tf) creates a continuous-time PID controller in parallel form with a first-order derivative filter: Ki Kd*s Kp + ---- + -------- s Tf*s+1 The scalars Kp, Ki, Kd, and Tf specify the proportional gain, integral gain, derivative gain, and filter time constant. The Tf value must be nonnegative for stability. The default values are Kp=1, Ki=0, Kd=0, and Tf=0. If a parameter is omitted, its default value is used. For example, PID(Kp,Ki,Kd) creates a PID controller with pure derivative term. The resulting SYS is of type PID if Kp,Ki,Kd,Tf are all real, and of type GENSS if one of the gains is tunable (see REALP and GENMAT). SYS = PID(Kp,Ki,Kd,Tf,Ts) creates a discrete-time PID controller with sample time Ts>0. The discrete-time PID formula is Kd Kp + Ki * IF(z) + -------------- Tf + DF(z) where IF(z) and DF(z) are the discrete integrator formulas for the integral and derivative terms. Use the "IFormula" and "DFormula" properties to specify these formulas. Available formulas include: 'ForwardEuler' Ts/(z-1) 'BackwardEuler' Ts*z/(z-1) 'Trapezoidal' (Ts/2)*(z+1)/(z-1) The default formula is ForwardEuler. The 'IFormula' and 'DFormula' settings are ignored for continuous-time PIDs. The following settings are disallowed because they generate unstable PIDs: (1) (Kd > 0, Tf = 0) and DFormula='Trapezoidal' (2) (Kd > 0, Tf > 0) and DFormula='ForwardEuler' and Ts>=2*Tf You can set additional properties by using name/value pairs. For example, sys = pid(1,2,3,0.5,0.1,'IFormula','T','TimeUnit','min') also specifies the integral-term formula and the time units. Type "properties(pid)" for a complete list of PID properties, and type help pid.<PropertyName> for help on a particular property. You can create arrays of PID objects by specifying arrays of values for Kp,Ki,Kd,Tf. For example, if Kp and Ki are 3-by-4 arrays, PID(Kp,Ki) creates a 3-by-4 array of PID controllers. Conversion: PIDSYS = PID(SYS) converts the dynamic system SYS to a PID object. An error is thrown when SYS cannot be expressed as a PID controller in parallel form. PIDSYS = PID(SYS,'IFormula',Value1,'DFormula',Value2) returns an equivalent PID controller with different formulas for the integral and derivative terms. See also PIDSTD, PID2, PIDSTD2, tunablePID, tunablePID2, TF. Documentation for pid doc pid Other uses of pid DynamicSystem/pid StaticModel/pid
  1 Commento
Anthony Santana
Anthony Santana il 4 Mar 2023
Thanks. I deleted the Control toolbox. No improvement.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by