dde23: Derivative and history vectors have different lengths.
4 ビュー (過去 30 日間)
古いコメントを表示
Hi, I'm trying to solve a very basic set of time-delay differential equations with dde23. All my code is below. collFunc2 is the driver, which sets three time lags -- taui, taug, tauf -- and calls dde23 on the set of three coupled differential equations -- dnidt -- in collFunc2. The history values are constant and zero in coll2hist. When I try to run this I get 'Derivative and history vectors have different lengths.' Both seem to be three columns long to me. What am I doing wrong? Thanks so much for any help. - Sylvia
function sol = collision2
taui = 15*60;
taug = 30*60; % graupel growth time
tauf = 10*60; % fallout time
lags = [taui, taui + taug, taui + taug + tauf];
sol = dde23(@collFunc2,lags,@coll2hist,[0,1000]);
function [t,dnidt] = collFunc2(t,y,Z)
alpha = 2.4*10^(-5); % volume sweep out rate [m3 s-1]
N = 50; % multiplication rate
ylag1 = Z(:,1); ylag2 = Z(:,2); ylag3 = Z(:,3);
dnidt(1) = alpha*N*((y(2)*y(3) - ylag1(2)*ylag1(3)));
dnidt(2) = alpha*N*(ylag1(2)*ylag1(3) - ylag2(2)*ylag2(3));
dnidt(3) = alpha*N*(ylag2(2)*ylag2(3) - ylag3(2)*ylag3(3));
function s = coll2hist(~)
% Constant history function
s = [0; 0; 0];
0 件のコメント
採用された回答
Walter Roberson
2015 年 5 月 14 日
The output of the delay differential equation is expected to have a single output that is a column vector that is the derivatives. Instead you have two outputs, the first of which is a copy of the time. But the time is a scalar, and a scalar does not match the history vector size of being a 3x1 vector.
3 件のコメント
Walter Roberson
2015 年 5 月 14 日
No, you created dnidt as a row vector. When you have a scalar and you extend it by assigning to the second element using
A(2) = VALUE
then the result is a row vector.
You can assign
dnidt = zeros(3,1);
or you can assign to
dnidt(2,1) = value;
or you can use
dnidt = dnidt.'
at the end.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Delay Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!