Error Message "Input argument 't' might be unused" OR "Not enough Input Arguments"
Show older comments
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)
Star Strider
on 30 Apr 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 Comments
Cheyenne Warren
on 30 Apr 2020
Star Strider
on 1 May 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Categories
Find more on Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!