Reputation: 745
I'm new to R and I'm trying to construct a minimal working example for solving an ODE. I want to solve dy/dt = y with initial condition y(0) = 1. I don't have any parameters, so I tried putting params = NULL
and I also tried omitting the argument altogether, which gave me the following error:
Error in func(time, state, parms, ...) : unused argument (parms).
Given that I don't have any parameters, I'm not sure what to do. My code is below.
library(deSolve)
dydt <- function(y,t) {
ydot <- y
return(ydot)
}
tvals = c(0:5)
y0 = 1
out <- ode(y = y0, times = tvals, func = dydt, parms = NULL)
Upvotes: 1
Views: 160
Reputation: 4480
library(deSolve)
dydt <- function(t,y,parms) {
ydot <-y
list(ydot)
}
tvals = c(0:5)
y0 =1
out <- ode(y = y0, parms=NULL,times = tvals, func = dydt)
As you can see from ?ode
:
list(ydot)
instead of return(ydot)
Best!
Upvotes: 2