Too many input arguments Error using Polyfit..HELP!!!

global I1 I2 P SynM s G D L Polar k;
I1=200; % Moment of intertia of motor (kgm^2)
I2=3000; % Moment of intertia of fan (kgm^2)
P=1000000; % Motor Power
SynM=1500; % Motor synchronous speed RPM
s=0.05; % Motor slip
G=80000000000; % Shaft modulus of Rigidity
D=0.2; % Shaft Diameter
L=1; % Shaft Length
Polar=0.0001571; % (pi*(D^4)/32) – Polar moment of Inertia
k=12568000; % stiffness = (G*J)/L
t0=0; % start time of simulation
tf=60; % end time of simulation
Tf1=P/((2*pi/60)*((1-s)*SynM));
% Torque with full load
M=[0; 20; 40; 60; 65; 70; 75; 80; 85; 90; 95; 100];
% percentage of motor synchronous speed
T=[150; 176; 212; 268; 282; 289; 296; 290; 262; 200; 100; 0];
% percentage of torque with full load
Tm=Tf1.*(T./100);
% Torque motor in N.m
Tf=(0.0033).*(((SynM*(2*pi/60)).*(M./100)).^2);
% Torque fan in N.m
P1=polyfit(((SynM*(2*pi/60)).*(M./100)),Tm,6);
% Coefficient %Pm=polyval(P,Sm); % value of y axis
P2=polyfit(((SynM*(2*pi/60)).*(M./100)),Tf,4);
% Pf=polyval(P2,Sm);
x=[0; 0; 0; 0];
% initial value for z_dot in assignment_function
options=odeset('abstol',1e-6,'reltol',1e-6);
% set value to -6 maximum
[t,z]=ode45('assignment_function',[t0 tf],x,options);
% used ode45 function
plot(t,z); % plot graph
subplot(2,1,1);
plot(t,z(:,2),'r',t,z(:,4),'g');
grid;
title('Angular Velocity against Time');
xlabel('Time (s)');
ylabel('Angular Velocity (rad/s)');
legend('Motor','Fan');
subplot(2,1,2);
plot(t,z(:,1)-z(:,3));
grid;
title('Angle of Twist against Time');
xlabel('Time (s)');
ylabel('Angle of Twist (Rad)');
legend('Angle of twist');
Error using polyfit
Too many input arguments.
Error in Testrun (line 30)
P2=polyfit(((SynM*(2*pi/60)).*(M./100)),Tf,4);

20 comentarios

KSSV
KSSV el 2 de Nov. de 2020
Check the dimensions of input. You have to input 1D arrays...Read the documentation.
Danish Teo
Danish Teo el 2 de Nov. de 2020
Does this mean i Cant put any Matrix inside?
KSSV
KSSV el 2 de Nov. de 2020
There is no error with the polyfit with shown code.
Danish Teo
Danish Teo el 2 de Nov. de 2020
But the error still persists.. I cant solve it..
Bruno Luong
Bruno Luong el 2 de Nov. de 2020
Editada: Bruno Luong el 2 de Nov. de 2020
Can you tell us what is result of
which polyfit
Danish Teo
Danish Teo el 3 de Nov. de 2020
There is no results.. it just Displays ' Too many input argument ' Error
@Danish Type
which polyfit
in workspace and tell us what it shows up. This is what Bruno Luong meant. We suspect that there might be a user defined polyfit function. You are using that instead of inbuilt function.
Danish Teo
Danish Teo el 3 de Nov. de 2020
Editada: Danish Teo el 3 de Nov. de 2020
>> which polyfit
D:\mATLAB\toolbox\matlab\polyfun
\polyfit.m
This is the Results
The function is inbuilt function.....Are you sure the given code you are running? I am getting the following error when I run your code.
global I1 I2 P SynM s G D L Polar k;
I1=200; % Moment of intertia of motor (kgm^2)
I2=3000; % Moment of intertia of fan (kgm^2)
P=1000000; % Motor Power
SynM=1500; % Motor synchronous speed RPM
s=0.05; % Motor slip
G=80000000000; % Shaft modulus of Rigidity
D=0.2; % Shaft Diameter
L=1; % Shaft Length
Polar=0.0001571; % (pi*(D^4)/32) – Polar moment of Inertia
k=12568000; % stiffness = (G*J)/L
t0=0; % start time of simulation
tf=60; % end time of simulation
Tf1=P/((2*pi/60)*((1-s)*SynM));
% Torque with full load
M=[0; 20; 40; 60; 65; 70; 75; 80; 85; 90; 95; 100];
% percentage of motor synchronous speed
T=[150; 176; 212; 268; 282; 289; 296; 290; 262; 200; 100; 0];
% percentage of torque with full load
Tm=Tf1.*(T./100);
% Torque motor in N.m
Tf=(0.0033).*(((SynM*(2*pi/60)).*(M./100)).^2);
% Torque fan in N.m
P1=polyfit(((SynM*(2*pi/60)).*(M./100)),Tm,6);
% Coefficient %Pm=polyval(P,Sm); % value of y axis
P2=polyfit(((SynM*(2*pi/60)).*(M./100)),Tf,4);
% Pf=polyval(P2,Sm);
x=[0; 0; 0; 0];
% initial value for z_dot in assignment_function
options=odeset('abstol',1e-6,'reltol',1e-6);
% set value to -6 maximum
[t,z]=ode45('assignment_function',[t0 tf],x,options);
Error using feval
Unrecognized function or variable 'assignment_function'.

Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.

Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
% used ode45 function
plot(t,z); % plot graph
subplot(2,1,1);
plot(t,z(:,2),'r',t,z(:,4),'g');
grid;
title('Angular Velocity against Time');
xlabel('Time (s)');
ylabel('Angular Velocity (rad/s)');
legend('Motor','Fan');
subplot(2,1,2);
plot(t,z(:,1)-z(:,3));
grid;
title('Angle of Twist against Time');
xlabel('Time (s)');
ylabel('Angle of Twist (Rad)');
legend('Angle of twist');
Danish Teo
Danish Teo el 3 de Nov. de 2020
Does the Matlab version matter?.. I am using the same code and the Same "Too many input argument " Error Persists..
KSSV
KSSV el 3 de Nov. de 2020
Polyfit remains same in all the version according my knowledge.
When the error occurs please tell us class() of each of the variables mentioned in the line that is causing the problem.
ans =
'double'
The class are all 'Doubles'
Please
edit polyfit
and show us what the first line of the file is.
function x_dot=LSCA1(t,x)
clc;
global Im If k P P2;
x_dot(1)=x(2);
x_dot(2)=((k/Im)*x(3))-((k/Im)*x(1))+(polyval(P,x(2))/Im);
x_dot(3)=x(4);
x_dot(4)=((k/If)*x(1))-((k/If)*x(3))-(polyval(P2,x(4))/If);
x_dot=x_dot';
Could you confirm that is what you get when you ask to edit polyfit? Because that is not even close to the right function.
Please also try
edit D:\mATLAB\toolbox\matlab\polyfun\polyfit.m
to verify that you really have overwritten the Mathworks version
function x_dot=assignment_function(t,x)
clc;
global Im If k P P2;
x_dot(1)=x(2);
x_dot(2)=((k/Im)*x(3))-((k/Im)*x(1))+(polyval(P,x(2))/Im);
x_dot(3)=x(4);
x_dot(4)=((k/If)*x(1))-((k/If)*x(3))-(polyval(P2,x(4))/If);
x_dot=x_dot';
This is the correct one
Danish Teo
Danish Teo el 3 de Nov. de 2020
How do i Return the function to normal if i have overwritter my matlab Polyfit function?
Bruno Luong
Bruno Luong el 3 de Nov. de 2020
Editada: Bruno Luong el 3 de Nov. de 2020
  • With luck you might have a copy polyfit.asv (but as we ask you to edit the file, it's no longer contains the original code).
  • Reinstall MATLAB.
  • Ask someone who has an intact installation to give you a file (though this is not totally legal to do).
Danish Teo
Danish Teo el 5 de Nov. de 2020
Thank you for the solution..It is Repaired my fellow mates

Iniciar sesión para comentar.

 Respuesta aceptada

Danish Teo
Danish Teo el 3 de Nov. de 2020

0 votos

Reinstalled.. Works Perfectly Fine now..

Más respuestas (0)

Preguntada:

el 2 de Nov. de 2020

Comentada:

el 5 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by