¿Por qué mi código no corre?

16 ビュー (過去 30 日間)
Luis Montenegro
Luis Montenegro 2020 年 9 月 3 日
回答済み: Rafael Hernandez-Walls 2020 年 9 月 4 日
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 件のコメント
Star Strider
Star Strider 2020 年 9 月 3 日
(Duplicate post.)

サインインしてコメントする。

回答 (1 件)

Rafael Hernandez-Walls
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

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by