¿Por qué mi código no corre?

16 次查看(过去 30 天)
Hola, he tratado de correr mi código toda la tarde y solo consigo el error de "not enough input arguments" y un error en la linea de T = T0... y no sé porqué. Necesito ayuda :(
Aquí están el código de la función y el principal
function dxdt = funcionVel(t,x)
M = 1200;
r = 0.25;
c = 20;
T0 = 1000;
t0 = 10;
T = T0*(1 - exp(-t/t0));
dxdt(1) = x(2);
dxdt(2) = T/(M*r) - c*x(2);
dxdt = dxdt';
end
%código principal abajo
clear variables
clc
t = (0:0.1:10);
condInicio = [0;0;0];
[T,Y] = ode45(@funcionVel,t,condInicio);
x1 = Y(:,1);
plot(t,x1)

回答(1 个)

Rafael Hernandez-Walls
Hola, Creo que tu condicion incial debe ser de solo dos elementos y no de tres. Intenta este programa principal, el cual llamará a tu función ya salvada.
clear all
clc
t = 0:0.1:10;
condInicio = [0;0];
[T,Y] = ode45(@funcionVel,t,condInicio);
x1 = Y(:,1);
plot(t,x1)
% Si te sirve mi sugerencia favor de aceptar como respuesta correcta

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by