How do I solve "too many input arguments" error ?

1 055 vues (au cours des 30 derniers jours)
Thierry
Thierry le 8 Juil 2014
Commenté : Walter Roberson le 11 Juin 2023
Hi there!
I'm facing, I guess a classical error. When I run the following code
clear all; close all; clc;
U=400.0;
S=150000;
Zn=(U^2)/S;
Phi=acos(0.8);
P=S*cos(Phi);
Xd=3.17*Zn;
Xq=1.9*Zn;
syms delta;
f11=(U*U/Xd)*sin(delta)+((U*U*(Xd-Xq))/(2*Xd*Xq))*sin(2*delta)-P;
delta=(180/pi)*solve(f11,delta)
I get a very long expression with figures, whose numeric solution can't be given because of the "too many input arguments error" in an atan function. I tried to use the eval func and the subs func. The subs func works but it seems like I don't get the same result when I use it regarding to when I compute the results parts by parts (that is a way to solve the problem actually, but I want to encode it).
I've looked on the web and didn't find any answer to my problem so please if you know about it .. thank you in advance.
  1 commentaire
José-Luis
José-Luis le 8 Juil 2014
The error message is pretty self-explanatory: you are passing more arguments than it is expecting to a function.
The most efficient way for you to solve that is to use the debugger. Stop just before the function call and look at what you are passing to it. Otherwise, people here can only guess: maybe a misplaced comma?

Connectez-vous pour commenter.

Réponses (9)

Nicholas Dureault
Nicholas Dureault le 20 Avr 2017
I ran into this problem the other day, turns out I had other paths added with the same file name. It took me about an hour of checking things back and forth to finally look closer at the debugger data telling me it was being pulled from another directory - ugh.
Hope that's not your issue, but it could be others :)
  7 commentaires
Robert Hamill
Robert Hamill le 27 Déc 2020
Thank you.
The which -all command was very helpful for my mistake. I had named a program the same as the command. Once I renamed the program, everything worked.
Jack Fogarty
Jack Fogarty le 3 Oct 2021
Ahh, thank you!

Connectez-vous pour commenter.


Roger Stafford
Roger Stafford le 8 Juil 2014
It is easy to express this solution in terms of a quartic equation in sin(delta) which could give you as many as four possible solutions for delta between -pi and +pi. Therefore you could solve it numerically using 'roots' and 'asin' appropriately. It is not necessary to use 'solve'.
  1 commentaire
Roger Stafford
Roger Stafford le 8 Juil 2014
To save you further anguish on your problem, Thierry, I used 'roots' on the quartic I described to you and found that for the parameters you defined it has no real-valued roots. That could easily account for the unexpected results you obtained with 'solve'. All its results, if it obtained any, would necessarily be complex-valued.

Connectez-vous pour commenter.


Jane Paik
Jane Paik le 24 Mai 2017
Hi,
I'm new to matlab and I keep facing an error message saying "Too many input arguments" when I try to extract epochs from the existing dataset.
Is there a way to solve this issue?
Thank you,
  3 commentaires
Cemre Vural
Cemre Vural le 23 Avr 2018
I wanted to write [exp(-0,5)-5*exp(1)]/(3^5-exp(2)) this but ıt keeps saying. "Error using exp Too many input arguments."
Walter Roberson
Walter Roberson le 23 Avr 2018
(exp(-0.5)-5*exp(1))/(3^5-exp(2))

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 24 Mai 2017
You should never eval() a symbolic expression. Symbolic expressions are not written in MATLAB: they are written in MuPAD, which is not quite the same as MATLAB.
One of the differences has to do with how the two-argument arctan is expressed. In MuPAD, both the single-argument arctan and the two-argument arctan use the same function call, but in MATLAB, the two-argument arctan is a separate call, atan2()
By the way, in R2017a, delta would come out as
-(log(root(z^4 + (541951709274448*z^3)/181125965994355 - (z^2*549755813888000i)/36225193198871 - (541951709274448*z)/181125965994355 - 1, z, 1))*1007958012753983i)/17592186044416
with no arc tangent involved. If you vpa() that then the result is complex.

Komal Khandare
Komal Khandare le 6 Juin 2018
Modifié(e) : Walter Roberson le 6 Juin 2018
Hi,
I'm new to matlab and I keep facing an error message saying "Too many input arguments".
for this code
for i = 1:10
writeDigitalPin(a, 'D11', 0);
pause(0.5);
writeDigitalPin(a, 'D11', 1);
pause(0.5);
end
Is there a way to solve this issue?
Thank you,
  1 commentaire
Walter Roberson
Walter Roberson le 6 Juin 2018
Nothing obvious there. What shows up for
which -all writeDigitalPin

Connectez-vous pour commenter.


vaya putra
vaya putra le 2 Juil 2018
Modifié(e) : Walter Roberson le 2 Juil 2018
(T)rho_r.*(1-(((T-273)-3.9863).^2/508929.2).*((((T-273)+288.9414)./((T-273)+68.12963))))
Too many input arguments.
anyone could help me
  1 commentaire
Walter Roberson
Walter Roberson le 2 Juil 2018
Is there a @ just before all of that?
How is the function being invoked? The error message indicates that you are trying to call it with two parameters.
For example if you had
fun = @(T) rho_r.*(1-(((T-273)-3.9863).^2/508929.2).*((((T-273)+288.9414)./((T-273)+68.12963))))
ode45(fun, tspan, x0)
then you could get the error because the ode*() routines always pass at least two parameters to the function: the current time, and the current boundary conditions (typically written as @(t,x) or @(t,y) ). If you were trying to use the above with ode45 you would need
fun = @(T, x) rho_r.*(1-(((T-273)-3.9863).^2/508929.2).*((((T-273)+288.9414)./((T-273)+68.12963))))
or
fun = @(t, T) rho_r.*(1-(((T-273)-3.9863).^2/508929.2).*((((T-273)+288.9414)./((T-273)+68.12963))))

Connectez-vous pour commenter.


Saranya Kumaraswamy
Saranya Kumaraswamy le 28 Avr 2021
Modifié(e) : Saranya Kumaraswamy le 28 Avr 2021
function dydx = ex8ode01(y)
P = 0.7;
dydx=zeros(6,1);
dydx(3)=( y(2)^2 - y(1)*y(3));
dydx(5)=-y(1)*y(5) - 1;
dydx(7)=-P*y(1)*y(7);
end
this is my code sir . got error 'Error using ex8ode01 .Too many input arguments.' is there any way to solve this?
  1 commentaire
Walter Roberson
Walter Roberson le 28 Avr 2021
That is obviously an ode function. ode functions must accept both time and boundary conditions, even if they do not need them for the calculation.

Connectez-vous pour commenter.


AYGUN JABRAYILOVA
AYGUN JABRAYILOVA le 19 Juil 2021
function x = myNewtonImprv(f, fd,x0,tol)
%Use the Newton-Rhapsom method with a tolerance or error check%
x = x0;
y = f(x);
while abs(y) > tol % Do this until tolerance is reached %
x = x - y/fd(x);
y = f(x);
end
end
too many arguments
  1 commentaire
Walter Roberson
Walter Roberson le 19 Juil 2021
We do not know how you are calling this code.

Connectez-vous pour commenter.


M.danyal Zahid
M.danyal Zahid le 11 Juin 2023
Modifié(e) : Walter Roberson le 11 Juin 2023
p1 = simout1.Pitch_angle__deg_;
p2 = simout1.P__pu_;
p3 = simout1.Q__pu_;
p4=simout1.wr__pu_;
p5 = simout;
p6=Frequency_A1;
p7=simout3.Output_active_power___Peo__pu_;
p8=simout3.Output_reactive_power__Qeo__pu_;
subplot(2,2,1)
plot(p1);
title('Pitch Angle(deg.)');
ylabel('Pitch Angle(deg.)');
axis([20 250 0 7])
grid on
subplot(2,2,2)
plot(p2);
title('Active Power(p.u)- Wind Turbine');
axis([20 250 0.23 0.4])
grid on
subplot(2,2,3)
plot(p3);
title('Reactive Power(p.u)- Wind Turbine');
axis([20 250 -.2 0])
grid on
subplot(2,2,4)
plot(p4);
title('Rotor Speed - Wind Turbine');
axis([20 250 1 1.25])
grid on
figure
subplot(2,2,1)
plot(p6);
title('Frequency');
axis([20 250 59.5 60.5])
grid on
subplot(2,2,2)
plot(p5);
title('Voltage at the PCC(p.u)');
ylabel('Voltage at the PCC(p.u)');
axis([20 250 0.9 1.1])
grid on
subplot(2,2,3)
plot(p7);
title('Active Power(p.u)- Synchronous');
axis([20 250 0.4 0.6])
grid on
subplot(2,2,4)
plot(p8);
title('Reactive Power(p.u)- Synchronous');
axis([20 250 -0.2 0])
grid on
Error in Over_AGC_Proposed_ERSC_Parameter_Plots (line 1)
p1 = simout1.pitch_angle__deg_;
i ma facing this issue .can anyone please guide me whats the cause of an issue ?
  1 commentaire
Walter Roberson
Walter Roberson le 11 Juin 2023
You do not show us what MATLAB thinks the error is
The current discussion is about "too many input arguments". You are indicating you have a problem with
p1 = simout1.pitch_angle__deg_;
Is it possible in MATLAB for "too many input arguments" to show up on that line?
If simout1 were a "package" and pitch_angle__deg_ were a function in the package, so file +simout1/patch_angle__deg_.m then that line would invoke the function with no parameters -- but "no parameters" is never "too many input parameters" so "too many" cannot occur on that line. Such an error could potentially occur on a function caleld by +simout1/patch_angle__deg_.m but the traceback would show at least one more line in such a case.
If simout1 were an object and pitch_angle__deg_ were a method defined for the object class, then pitch_angle__deg_ would be called with the object as a parameter, as if pitch_angle__deg_(simout1) had been called. Could that be a case of too many input parameters? Could a method pitch_angle__deg_ be defined in a way that did not permit input parameters?
If pitch_angle__deg_ were an ordinary method of the class and it were incorrectly designed to not accept an object of the class of the method, then MATLAB would generate a different error message specifically about needing to have a parameter of the appropriate class. So that is out.
But... if simout1 were an object of a class named pitch_angle__deg_ then pitch_angle__deg_ would be the class constructor, and class constructors can be defined to not accept any parameters.
So in order for the too many input parameters error to occur on the indicated line, you would have had to have
classdef pitch_angle__deg_
function obj = pitch_angle__deg_()
obj = something
end
end
and simout1 would have to have been constructed from the class pitch_angle__deg_ and then simout1.pitch_angle__deg_ would be an attempt to call pitch_angle__deg_(simout1) which would fail.
So it is not impossible to get such an error on that line... it is just rather unlikely.
I would suggest to you that you chopped off important parts of the error message.
My speculation is that the actual problem is that you do not have an object or struct named simout1 at the time you invoke script Over_AGC_Proposed_ERSC_Parameter_Plots.m

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by