Why does Matlab tell me that my ODE function returns a vector of length 12, while the length of my initial conditions vector is 6?
Show older comments
Hi there!
I'm getting an error message from Matlab, telling me that my ODE model returns a vector of length 12, while the length of my initial conditions vector is 6. The state vector I've defined in my ODE function file, at the beginning of my code, is:
xG = z(1);
yG = z(2);
theta = z(3);
vGx = z(4);
vGy = z(5);
omega = z(6);
and, therefore, my first three, simple ODEs is [z(4);z(5);z(6)], and the last three ODEs are the derivatives of z(4), z(5), and z(6). So, it seems to me that I wrote a function that returns a vector of length 6, not the 12 that Matlab is suggesting.
What have I done wrong?
Thanks in advance,
2 Comments
MATLAB won't tell you that you return a vector of length 12 if you return a vector of length 6. But we must see your code to tell you what's going wrong.
You can easily determine the length of the vector returned to the ODE integrator by using
size(dydt)
at the end of your ODE function if "dydt" is the name of the output from your function.
Noob
on 26 Nov 2024
Accepted Answer
More Answers (0)
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!