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

9 ビュー (過去 30 日間)
CHOI HYUNDUK
CHOI HYUNDUK 2018 年 11 月 16 日
コメント済み: CHOI HYUNDUK 2018 年 11 月 17 日
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".
CHOI HYUNDUK
CHOI HYUNDUK 2018 年 11 月 17 日
@Torsten I am sorry, Torsten. I tried again seeing you answer!

サインインしてコメントする。

採用された回答

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 Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by