ODE45 say ' must return a column vector' with experiment data.

2 次查看(过去 30 天)
When I use ODE 45 with velocity1 [9000x1] vector , it doesn't work well.
So I have a question.
I used 'interp1' for chagning [9000x1] to [1x9000] vector.
But when i run this, it says "@(TIME,X)G(TIME,X) must return a column vector".
So when I attach interp1 into ode45 like "ode45(@(time,x) interp1(t, g(time, x),time), time, 0.003);
xa2 has only "y=0.003".
Could you help me how to solve this problem? Thank you so much.
v = interp1(time, velocity1, t1);
g = @(time, x) -abs(v)*a(4)*x(1)*abs(x(1))^(n-1)-a(5)*v*abs(x(1))^n+a(6)*v;
[time, xa2] = ode45(@(time,x) g(time, x), time, 0.003);
  5 个评论
Torsten
Torsten 2018-11-16
@CHOI HYUNDUK: I wonder why you can't just take the code I supplied.
The variable "time" in your call to interp1 is at the wrong position ; it has to be the last, not the first input parameter to "interp1".

请先登录,再进行评论。

采纳的回答

Jan
Jan 2018-11-16
"I used 'interp1' for chagning [9000x1] to [1x9000] vector." This is not the right job for an interpolation, but this is simply a transpose().
The posted code does not run due to the missing variables. Please post running code, such that we can check a suggested solution without the need to guess, what inputs you have.
ODE45 is not designed to process a non-differentiable function. The linearily interpolated data are not differentiable, so you run the integration outside the numerical specifications. This replies a final value, but you might get a huge accumulated rounding error.
Defining the function to be integrated as anonymous functions impedes the debugging. If you use a standard function instead and provide the parameters only by an anonymous function (see Answers: Anonymous for params), you can simply set a breakpoint in the function and check the cause of the error message. The error message claims "that the function does not reply a column vector" - but if your initial value is a scalar, the function to be integrated must reply a scalar also. Therefore it is not clear, why the output depends on "-abs(v)" at all.

更多回答(0 个)

类别

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