Not enough input arguments

조회 수: 5 (최근 30일)
Anthony Santana
Anthony Santana 2023년 3월 3일
답변: Walter Roberson 2023년 3월 4일
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
Walter Roberson
Walter Roberson 2023년 3월 4일
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 2023년 3월 4일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2023년 3월 4일
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.

추가 답변 (1개)

Les Beckham
Les Beckham 2023년 3월 3일
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
Anthony Santana
Anthony Santana 2023년 3월 4일
Thanks. I deleted the Control toolbox. No improvement.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 PID Controller Tuning에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by