I'm entering a function which returns an error, "requires more input parameters to run,"

The function looks something like this:
if true
function dy = pendode2(t,y)
dy= zeros(2,1); % a column vector
A=110;
B=0.01;
C=0.001;
g=9.81;
L = (3*g)/(2*A);
omega=0.002;
% E=0.00011;
E=0.2;
d=80e-3;
h= d+L(1-cos(y(2)));
r= ((Lsin(y(2)))^2+(h)^2)^0.5;
dy(1)=Asin(y(2))+Bsin(omega*t)-C*y(1)+cross((abs(y(2))/y(2))*(E/r^2),cos(abs(y(2))+arctan(-abs(h/Lsin(y(2))))));
dy(2)= y(1);
end
and then in another command window, saved in the same directory I typed,
if true
options=odeset('RelTol',2.22045e-14,'AbsTol',[1e-14 1e-14]);
[t,y]=ode113(@pendode2, [0 1000], [0 0.2], options);% code
end
CAN SOMEBODY PLEASE HELP IM DYING, IT SHOULD GIVE OUT TWO VECTORS, ONE FOR T AND ONE FOR Y.

2 Comments

h= d+L(1-cos(y(2)));
r= ((Lsin(y(2)))^2+(h)^2)^0.5;
dy(1)=Asin(y(2))+Bsin(omega*t)-C*y(1)+cross((abs(y(2))/y(2))*(E/r^2),cos(abs(y(2))+arctan(-abs(h/Lsin(y(2))))));
what's Lsin ,Asin, Bsin??
A is just a parameter which have given the value 110, B=0.01 and so on. Asin((y(2)) is just a sine function.

Sign in to comment.

 Accepted Answer

options=odeset('RelTol',2.22045e-14,'AbsTol',[1e-14 1e-14]);
[t,y]=ode113(@pendode2, [0 1000], [0 0.2], options);
function dy = pendode2(t,y)
dy= zeros(2,1); % a column vector
A=110;
B=0.01;
C=0.001;
g=9.81;
L = (3*g)/(2*A);
omega=0.002;
% E=0.00011;
E=0.2;
d=80e-3;
h= d+L*(1-cos(y(2)));
r= ((L*sin(y(2)))^2+(h)^2)^0.5;
dy(1)=A*sin(y(2))+B*sin(omega*t)-C*y(1)+atan(-abs(h/L*sin(y(2))));
dy(2)= y(1);
end
it was a lot of pain debugging your code , by the way I removed
cross((abs(y(2))/y(2))*(E/r^2),cos(abs(y(2))
because wasn't clear

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!