Error Message "Input argument 't' might be unused" OR "Not enough Input Arguments"
Afficher commentaires plus anciens
function dvdt = deqn(t,v,M,G,K)
dvdt = [v(1); G-((K/M)*(v^2))];
M = 5;
K = 0.125;
G = 32;
tspan = (0:5);
v0 = [0 0];
[t,v] = ode45(@(t,v) odefun(t,v,M,G,K), tspan, v0);
plot(t,v)
Can anyone help me fix this? I need 't' to graph a velocity versus time function using this ODE.
Réponses (1)
Star Strider
le 30 Avr 2020
Try this:
odefun = @(t,v,M,G,K) [v(1); G-((K/M)*(v(2)^2))]; % Guessing That The ‘v^2’ Term Should Be ‘v(2)^2’
M = 5;
K = 0.125;
G = 32;
tspan = (0:5);
v0 = [0 0];
[t,v] = ode45(@(t,v) odefun(t,v,M,G,K), tspan, v0);
plot(t,v)
That worked when I ran it (R2020a).
2 commentaires
Cheyenne Warren
le 30 Avr 2020
Star Strider
le 1 Mai 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!