MATLAB ODE45:只保存最后一个解决方案
MATLAB ODE45: only saving last solution
我只想让 ODE45 保留最后一个解。而是返回 tspan = [t0 tf] 中的所有解决方案;我只希望返回的向量是 tf.
处的解
我之所以这样做是为了避免出现以下错误:
Error using horzcat Requested 442368x1828 (6.0GB) array exceeds
maximum array size preference. Creation of arrays greater than this
limit may take a long time and cause MATLAB to become unresponsive.
See array size limit or preference panel for more information.
Error in ode45 (line 428)
yout = [yout, zeros(neq,chunk,dataType)];
来自文档:
tspan — Interval of integration
vector
Interval of integration, specified as a vector. At minimum, tspan must be a two element vector [t0 tf] specifying the initial and final times. To obtain solutions at specific times between t0 and tf, use a longer vector of the form [t0,t1,t2,...,tf]. The elements in tspan must be all increasing or all decreasing.
The solver imposes the initial conditions, y0, at tspan(1), then integrates from tspan(1) to tspan(end):
If tspan has two elements, [t0 tf], then the solver returns the solution evaluated at each internal integration step within the interval.
If tspan contains more than two elements [t0,t1,t2,...,tf], then the solver returns the solution evaluated at the given points. This does not affect the internal steps that the solver uses to traverse from tspan(1) to tspan(end). Thus, the solver does not necessarily step precisely to each point specified in tspan. However, the solutions produced at the specified points are of the same order of accuracy as the solutions computed at each internal step.
Specifying several intermediate points has little effect on the efficiency of computation, but for large systems it can affect memory management.
The solution obtained by the solver might be different depending on whether you specify tspan as a two-element vector or as a vector with intermediate points. If tspan contains several intermediate points, then they give an indication of the scale for the problem, which can affect the size of the initial step taken by the solver.
所以只需指定三点。 [t0 (t0+tf)/2 tf]
我只想让 ODE45 保留最后一个解。而是返回 tspan = [t0 tf] 中的所有解决方案;我只希望返回的向量是 tf.
处的解我之所以这样做是为了避免出现以下错误:
Error using horzcat Requested 442368x1828 (6.0GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.
Error in ode45 (line 428) yout = [yout, zeros(neq,chunk,dataType)];
来自文档:
tspan — Interval of integration vector Interval of integration, specified as a vector. At minimum, tspan must be a two element vector [t0 tf] specifying the initial and final times. To obtain solutions at specific times between t0 and tf, use a longer vector of the form [t0,t1,t2,...,tf]. The elements in tspan must be all increasing or all decreasing.
The solver imposes the initial conditions, y0, at tspan(1), then integrates from tspan(1) to tspan(end):
If tspan has two elements, [t0 tf], then the solver returns the solution evaluated at each internal integration step within the interval. If tspan contains more than two elements [t0,t1,t2,...,tf], then the solver returns the solution evaluated at the given points. This does not affect the internal steps that the solver uses to traverse from tspan(1) to tspan(end). Thus, the solver does not necessarily step precisely to each point specified in tspan. However, the solutions produced at the specified points are of the same order of accuracy as the solutions computed at each internal step. Specifying several intermediate points has little effect on the efficiency of computation, but for large systems it can affect memory management. The solution obtained by the solver might be different depending on whether you specify tspan as a two-element vector or as a vector with intermediate points. If tspan contains several intermediate points, then they give an indication of the scale for the problem, which can affect the size of the initial step taken by the solver.
所以只需指定三点。 [t0 (t0+tf)/2 tf]