¿Por qué mi código no corre?
조회 수: 4 (최근 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
2020년 9월 4일
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!