Not enough input arguments.

10 vues (au cours des 30 derniers jours)
Air Roland Dela Cruz
Air Roland Dela Cruz le 9 Mai 2021
Modifié(e) : per isakson le 9 Mai 2021
Why do I get an error when create the M-File "Lorenz" with the following input:
function xprime = Lorenz(t,x);
%LORENZ: Computes the derivatives involved in solving the Lorenz equations
sig = 10;
beta = 8/3;
rho=28;
xprime=[-sig*x(1) + sig*x(2);rho*x(1)-x(2)-x(1)*x(3);-beta*x(3) +x(1)*x(2)];
The error says:
Error in Lorenz (line 6)
xprime=[-sig*x(1) + sig*x(2);rho*x(1)-x(2)-x(1)*x(3);-beta*x(3) +x(1)*x(2)];
  1 commentaire
per isakson
per isakson le 9 Mai 2021
Modifié(e) : per isakson le 9 Mai 2021
I get the error (R2018b)
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in Untitled2>Lorenz (line 11)
xprime=[-sig*x(1) + sig*x(2); rho*x(1)-x(2)-x(1)*x(3); -beta*x(3) +x(1)*x(2)];
Error in Untitled2 (line 4)
xprime = Lorenz( t, x );
I cannot see that this statement (Lorenz (line 6)) could throw the error "Not enough input arguments."
Show your full error message.

Connectez-vous pour commenter.

Réponse acceptée

per isakson
per isakson le 9 Mai 2021
Modifié(e) : per isakson le 9 Mai 2021
You need to call the function, Lorenz, with two input arguments: t and x. E.g.
%%
x = (1:6);
t = nan;
xprime = Lorenz( t, x )
In your case the variable, x, is not defined in the workspace of Lorenz. Thus, the expression cannot be evaluated. Don't ask me why the error message isn't more informative.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by