[R] Wrapper function for multivariate arrays for ode
Tjun Kiat Teo
teotjunk at gmail.com
Tue Jul 3 04:09:33 CEST 2012
I am trying to to write a wrapper function for the ode solver (under
the package desolve) to enable it to take multivariate arrays. I know
how to do it for 1 dimension arrays but my code breaks down when I try
to do it for 2 dimensional arrays. Here is my code
diffwrap<-function(t,y,mu)vdpol(t=t,A[1:3,1:4]<-y[1:12],B[1:12]<-y[13:24],mu=mu)
vdpol<-function(t,A,B,mu)
{
list(c(mu,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
A[1,1],
A[2,1],
A[3,1],
A[1,2],
A[2,2],
A[3,2],
A[1,3],
A[2,3],
A[3,3],
A[1,4],
A[2,4],
A[3,4])
)
}
stiff<-ode(y=rep(0,24),times=c(0,1),func=diffwrap,parms=1)
I get keep getting the error message variable A[1,1] not found.
More information about the R-help
mailing list