'...must return a column vector' errors when using ODE45
古いコメントを表示
Hi all,
Here's my function code:

and here's my solution code with the stated error:

I've not included a large amount of the code in the function as I don't believe my errors lies in there but if it'd help you help me I can add it.
I'm aiming at a solution that provides a 16x300 matrix, i.e. the value of 16 variables contained in x over 300 time steps. But Matlab is saying it must return a column vector. Is this the nature of ode45 or can I adapt my code somehow? My function is rejecting the input arguments as shown. What should they be here? The independent variable is t which defines x and Q, while all the remaining terms are constant.
Thanks in advance.
EDIT: Full code posted below
11 件のコメント
Star Strider
2015 年 12 月 3 日
編集済み: Star Strider
2015 年 12 月 3 日
That is difficult to read.
Your ‘xdot’ needs to be a column vector, that means ‘x’ also needs to be a column vector, not a (16x300) matrix. (I have no idea what ‘B*Q’ is.)
Keelan Toal
2015 年 12 月 4 日
Walter Roberson
2015 年 12 月 4 日
Please post actual code. The image of the code is not clear enough for me to make out (I have vision problems.)
Keelan Toal
2015 年 12 月 4 日
Walter Roberson
2015 年 12 月 4 日
[T,X]=ode45(@(t,x) myode1(t,x),Tspan,IC);
Notice no string!!
Keelan Toal
2015 年 12 月 4 日
Walter Roberson
2015 年 12 月 4 日
xdot = xdot(:);
right you compute xdot.
Torsten
2015 年 12 月 4 日
A*x is 16x1 and B*Q is 16x300. Incompatible.
Best wishes
Torsten.
Walter Roberson
2015 年 12 月 4 日
Ah. We could show how to expand the A*x to be 16x300 itself, but I suspect that the poster wants a result of length 16 not a result of length 16*300 ...
Keelan Toal
2015 年 12 月 4 日
Torsten
2015 年 12 月 4 日
function xdot = myode1(t,x)
Here, t is 1x1 and x is 16x1.
So, you have to evaluate Q1, Q2, Q3 and Q4 at this special time t. If you do this, Q will be 4x1 and everything is fine.
Best wishes
Torsten.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
