¿Por qué mi código no corre?

25 views (last 30 days)
Luis Montenegro
Luis Montenegro on 3 Sep 2020
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)

Answers (1)

Rafael Hernandez-Walls
Rafael Hernandez-Walls on 4 Sep 2020
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

Community Treasure Hunt

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

Start Hunting!