Error Message "Input argument 't' might be unused" OR "Not enough Input Arguments"

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.

Answers (1)

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 Comments

My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Asked:

on 30 Apr 2020

Commented:

on 1 May 2020

Community Treasure Hunt

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

Start Hunting!