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

조회 수: 5 (최근 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 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