我有一个颂歌系统,
我想根据时间 t 绘制 V1 和 V2。我的代码是
library("deSolve")
library("reshape")
library("tidyverse")
parameters <- c(tau = 0.005, tau_r = 0.0025, mui=0, Ve=0.06, Vi=-0.01, s=0.015, mue=10000)
state <- c(X = 0.015, Y = 0)
Odesolver <-function(t, state, parameters) {
with(as.list(c(state, parameters)),{
# rate of change
dX <- -(1/tau + mue - mui)*X + (Y-X)/tau_r + mue*Ve - mui*Vi
dY <- -Y/tau + (X-Y)/tau_r
# return the rate of change
list(c(dX, dY))
}) # end with(as.list ...
}
times <- seq(0, 100, by = 0.01)
out <- ode(y = state, times = times, func = Odesolver, parms = parameters)
out.df = as.data.frame(out)
out.m = melt(out.df, id.vars='time')
p <- ggplot(out.m, aes(time, value, color = variable)) + geom_point() +theme_classic()
print(p)
我做对了吗?还有一种方法可以让我绘制1/t
改变的值mue
吗?这两者都通过第一颂相关联。