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

조회 수: 1,001 (최근 30일)
Thierry
Thierry 2014년 7월 8일
댓글: Leonardo 2024년 6월 10일
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
José-Luis
José-Luis 2014년 7월 8일
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?

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

답변 (10개)

Nicholas Dureault
Nicholas Dureault 2017년 4월 20일
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 :)
  댓글 수: 8
Jack Fogarty
Jack Fogarty 2021년 10월 3일
Ahh, thank you!
Leonardo
Leonardo 2024년 6월 10일
greetings from the future, in my case which indicated that the desired directory was being used but this was not true. I renamed the files in other directories with the same name and now my script works correctly

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


Roger Stafford
Roger Stafford 2014년 7월 8일
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
Roger Stafford
Roger Stafford 2014년 7월 8일
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.

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


Jane Paik
Jane Paik 2017년 5월 24일
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
Cemre Vural
Cemre Vural 2018년 4월 23일
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 2018년 4월 23일
(exp(-0.5)-5*exp(1))/(3^5-exp(2))

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


Walter Roberson
Walter Roberson 2017년 5월 24일
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 2018년 6월 6일
편집: Walter Roberson 2018년 6월 6일
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
Walter Roberson
Walter Roberson 2018년 6월 6일
Nothing obvious there. What shows up for
which -all writeDigitalPin

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


vaya putra
vaya putra 2018년 7월 2일
편집: Walter Roberson 2018년 7월 2일
(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
Walter Roberson
Walter Roberson 2018년 7월 2일
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))))

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


Saranya Kumaraswamy
Saranya Kumaraswamy 2021년 4월 28일
편집: Saranya Kumaraswamy 2021년 4월 28일
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
Walter Roberson
Walter Roberson 2021년 4월 28일
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.

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


AYGUN JABRAYILOVA
AYGUN JABRAYILOVA 2021년 7월 19일
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
Walter Roberson
Walter Roberson 2021년 7월 19일
We do not know how you are calling this code.

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


M.danyal Zahid
M.danyal Zahid 2023년 6월 11일
편집: Walter Roberson 2023년 6월 11일
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
Walter Roberson
Walter Roberson 2023년 6월 11일
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

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


Arfa Ahmed
Arfa Ahmed 2024년 5월 13일
Hi! I'm doing PCA of a digit dataset and trying to scatter plot the z values with 2 components. I'm facing "too many arguements" error when I'm running this code.
scatter(z(:,1), z(:,2), 20, y, 'filled');
Further, the plot is not giving me multiple colors but only single color even after specifying the RGB parameter (which are the target values of dataset).
Can anyone help?

Community Treasure Hunt

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

Start Hunting!

Translated by