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

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 commentaires

in the text file you attached there are 4 columns what do they represent? what are the values of time , velocity and t1 in interp1?
That represnts [Time, acceleration, displacement, force].
But i remade time '(0:0.0006:5.3994)' like this to start from 0.
and t1 is the time trasposed.
and velocity1 was got by kalman filter using acc and displacement data.
So if you check the workspace , everything is just 9000x1 or 1x9000vector.
Thank you so much!
in the text file there are 4 columns please mention what datas they represent
@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".
@Torsten I am sorry, Torsten. I tried again seeing you answer!

Connectez-vous pour commenter.

 Réponse acceptée

Jan
Jan le 16 Nov 2018
"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.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by