Effacer les filtres
Effacer les filtres

What argument is Missing from this Function?

2 vues (au cours des 30 derniers jours)
Neil Solan
Neil Solan le 27 Fév 2018
I'm getting the 'Not Enough Input Arguments' error on my function and I can't for the life of me figure out why? Can someone point out what I'm missing?
function dtheta = nonlin_function(t,t_1,Theta)
if t>=(ceil(t/t_1)-1)*t_1 && t<=(ceil(t/t_1)-1)*t_1+t_1
F = (5/t_1)*(t-(ceil(t/t_1)-1)*t_1);
elseif t>=(ceil(t/t_1)-1)*t_1
F = 5;
end
dtheta = zeros(2,1);
dtheta(1) = Theta(2);
dtheta(2) = (666.67*(F-(((1*10^-4)*(cos(Theta(1))*cos(Theta(1)))+(10^-3))*Theta(2))-((0.01)*sin(Theta(1))*cos(Theta(1)))-(0.5*Theta(1))));
  1 commentaire
per isakson
per isakson le 27 Fév 2018
Not without knowing how you call the function. And seeing the full error message would help.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 27 Fév 2018
From the look of that you likely calling this from ode45 . The normal calling sequence for a function called by ode45 is name(t, y) though possibly with different names. In your situation it appears to me that would be nonlin_function(t, Theta) . Notice only two arguments are passed by default -- but your function is expecting three parameters. It appears that t_1 is the extra one that is not normally passed.
However, if I am correct that this is being called from one of the ode* routines, then your function is discontinuous in some circumstances, which is not permitted. For example for t = 0.01 then the function is discontinuous at 0.1 2.06 2.08 2.1 2.12 2.14 2.16 2.18 2.2 2.33 2.35 2.37 2.39 2.41 2.43 2.45 2.58 2.6 2.62 2.64 2.66 2.68 2.7 2.72 2.74 2.83 2.85 2.87 2.89 2.91 2.93 2.95 2.97 2.99 3.1 3.12 3.14 3.16 3.18 3.2 3.22 3.24 3.35 3.37 3.39 3.41 3.43 3.45 3.47 3.49 3.6 3.62 3.64 3.66 3.68 3.7 3.72 3.74 3.85 3.87 3.89 3.91 3.93 3.95 3.97 3.99 4.11 4.15 4.4 4.65 4.9 . You must create an event function to detect the change in smoothness of F and to stop the integration there, and then to restart on the other side of the boundary using the last output of the previous step as the new starting time and new initial conditions.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by