ODE45 say ' must return a column vector' with experiment data.
2 views (last 30 days)
Show older comments
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 Comments
Torsten
on 16 Nov 2018
@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".
Accepted Answer
Jan
on 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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!