MATLAB error: too many input arguments
Mostra commenti meno recenti
Hi, I'm trying to solve the variable length pendulum equation with ODE45
here are the codes:
-------------------------
%Pendulum of variable length: T is the period, th0 the initial conditions
%for the angulus and angular velocity, eta is the length parameter and g
%is the gravitational acceleration
%for the length law l(t) see 'el.m'
%for the motion equations see 'eq_varpend.m'
%usage: [t,th] = varpend
function [t,th] = varpend()
entries={
'T',...
'th0',...
'eta',...
'g',...
};
default={
'30*pi',...
'pi/6',...
'1.0',...
'9.8',...
};
setup = inputdlg(entries,'Variable length pendulum',1,default,'on');
T=str2num(setup{1});
th0=[str2num(setup{2}),0];
eta=str2num(setup{3});
g=str2num(setup{4});
opt=odeset('Abs',1e-10,'Rel',1e-10);
[t,th]=ode45('eq_varpend', [0,T], th0, opt, eta, g);
plot(t,th(:,1));
grid on
xlim([0 T])
title('Pendulum trajectory');
figure(2)
plot(th(:,1), th(:,2));
grid on
axis equal
title('Phase space');
------
%motion equation fot the v.l. pendulum
function dtheta = eq_varpend(t,th,eta,g)
[q,qdot] = el(t,eta);
dtheta = [ th(2) ; -g*sin(th(1))./q-2*th(2).*qdot./q; ];
------
%length law for the v.l. pendulum
function [q,qdot] = el(t,eta)
q = 1+eta*t;
qdot = eta;
------
When I type [t,th] = varpend I get the following error message:
Error using eq_varpend
Too many input arguments.
Can anyone help me? Thanks
Risposta accettata
Più risposte (1)
Enrico Picari
il 10 Feb 2013
0 voti
4 Commenti
the cyclist
il 10 Feb 2013
Please consider "accepting" my answer, which may help future users who have similar questions. (Also, in the future, it would have made more sense to make your remark a "comment" on my answer, rather than a separate answer.)
Enrico Picari
il 10 Feb 2013
dinesh reddy
il 9 Ott 2017
Modificato: Walter Roberson
il 9 Ott 2017
function [swav]=s_wav(x)
l=1;
x=x-l/6;
a=0.25;
b=15;
n=100;
s1=(a/(2*b))*(2-b);
s2=0;
for i = 1:n
harm3=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l);
s2=s2+harm3;
end
swav=-1*(s1+s2);
%%I generated the S wave of ecg signal by using the above code%%
%%By using below code i am running it and i was struck with an error called too many input arguments can any one help me%%
x=0.01:0.01:2;
default=input('press 2:\n');
rate=input('\n\nenter the heart beat rate :');
li=30/rate;
fprintf('\n\ns wave specifications\n');
a_swav=input('amplitude = ');
d_swav=input('duration = ');
swav=s_wav(x,a_swav,d_swav,t_swav,li);
Walter Roberson
il 9 Ott 2017
You define s_wav as taking 1 single parameter. Your call s_wav(x,a_swav,d_swav,t_swav,li) tries to provide 5 parameters to s_wav . Your exising s_wav code does not even appear to have any place it could use those extra parameters.
Categorie
Scopri di più su Simscape Multibody in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!