最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

date - The number of derivatives returned by func() (x) must equal the length of the initial conditions vector (y) - Stack Overf

programmeradmin4浏览0评论

I'm trying to define a parameter in my mathematical model "z", where my model is a system of ordinary differential equations, which is then solved using the function "ode" of the library "deSolve". The problem here is given by the fact that I'm trying to assign z = 1 if a certain condition is met (specifically, if we are in a date interval defined as a column of my dataframe "Temperatura2223"), and 0 if we are outside of this time interval.

So here the chunck:

  Start_22 = as.Date("2022-03-07")
  End_22 = as.Date("2022-10-03")
  Start_23 = as.Date("2023-03-10")
  End_23 = as.Date("2023-10-02")


  z = ifelse(
       (Temperatura2223$Data >= Start_22 & Temperatura2223$Data <= End_22) |
       (Temperatura2223$Data >= Start_23 & Temperatura2223$Data <= End_23),
    1,
    0
  ) 

Then "z" goes into two of my equations of the system:

  dE   = Y_Ao * (beta1 * A_1o + beta2 * A_2o) - (u_e + f_E(T, T_e, TDD_e) * z) * E

  dL   = z * f_E(T, T_e, TDD_e) * E - (m_L(T, u_l) * (1 + L / k_l) + f_L(T)) * L

then this error keeps occouring:

The number of derivatives returned by func() (216) must equal the length of the initial conditions vector (10).

Of course the initial conditions are 10, not two as the equations that I've reported here. I'm really stuck, also because I've already tried different solutions, such as creating a new column as "z" into my dataframe, or naming z as function and traslating it into numeric object, and in this way keeps giving the error "not numeric argument assigned to binary object".

Thanks in advance for any advice!

Of course the initial conditions are 10, not two as the equations that I've reported here. I'm really stuck, also because I've already tried different solutions, such as creating a new column as "z" into my dataframe, or naming z as function and traslating it into numeric object, and in this way keeps giving the error "not numeric argument assigned to binary object".

Thanks in advance for any advice!

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论