Error using ode45

8 次查看(过去 30 天)
esra ilhan
esra ilhan 2020-12-4
评论: esra ilhan 2020-12-4
Dears,
I am having an error for ODE45 usage:
XDOT_P12_7B returns a vector of length 2, but the length of the initial conditions vector is 3. The vector returned by
XDOT_P12_7B and the initial conditions vector must have the same number of elements.
I don't see where the problem comes from, I define in the function file 3 variables and my derivative matrix also has 3 components only thing one of my derivatives is equal (it represents constant T)
I would be appreciated if someone can help me with this,
Thank you

回答(2 个)

Bjorn Gustavsson
Bjorn Gustavsson 2020-12-4
Perhaps your calling has become too "traditional" and is not properly supported. In that case (and in general) it might be enough to change the calling of ode45 to:
[Vb,x]=ode45(@(V,x) xdot_P12_7b(V,x),Vspan,ic);

Alan Stevens
Alan Stevens 2020-12-4
You need to declare cpAB as a global variable in P12_7b. Better to try to do without global variables!
You have some other problems also, but as I don't have fsolve I can't do much more.
  1 个评论
esra ilhan
esra ilhan 2020-12-4
What are the other problems you see, I change the cpAB and updated ODE45 but still I have error

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by