Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

second order - delay differential equations - dde23

161 views
Skip to first unread message

Antony

unread,
Apr 22, 2014, 2:38:03 PM4/22/14
to
I am trying to solve second order delay differential equations. Naturally, I have converted them into two order differential equations. I am still getting an error. Please go through this. I would be glad and grateful if you can sort my problem out.

ddefun(1) and (2) represent my attempt convert my second order DE in two first order DE.
(These equations model thermoacoustic instabilities.)

This is the error I get.
" Undefined function 'Y' for input arguments of type 'double'.

Error in trail2DDE (line 39)
ddefun(1) = Y(2); "

But i checked the dde23 file in MATLAB, it says the following:
" DDE23 Solve delay differential equations (DDEs) with constant delays.
% SOL = DDE23(DDEFUN,LAGS,HISTORY,TSPAN) integrates a system of DDEs
% y'(t) = f(t,y(t),y(t - tau_1),...,y(t - tau_k)). The constant, positive
% delays tau_1,...,tau_k are input as the vector LAGS. DDEFUN is a function
% handle. DDEFUN(T,Y,Z) must return a column vector corresponding to
% f(t,y(t),y(t - tau_1),...,y(t - tau_k)). In the call to DDEFUN, a scalar T
% is the current t, a column vector Y approximates y(t), and a column Z(:,j)
% approximates y(t - tau_j) for delay tau_j = LAGS(J). The DDEs are
% integrated from T0=TSPAN(1) to TF=TSPAN(end) where T0 < TF. The solution
% at t <= T0 is specified by HISTORY in one of three ways: HISTORY can be
% a function handle, where for a scalar T, HISTORY(T) returns a column
% vector y(t). If y(t) is constant, HISTORY can be this column vector.
% If this call to DDE23 continues a previous integration to T0, HISTORY
% can be the solution SOL from that call."

The code is as follows:

sol = zeros(10,1);
lags = 0.01 ;
tspan = [0,5];
% parameters
tw = 1000;
t = 295;
lw = 3.6;
gamma = 1.4;
lamda = 0.0328;
cv = 719;
dw = 0.0005;
rhobar = 1.205;
xf = 0.7;
uo = 0.3;
s = 0.0016;
co = 344.64;
%c1 = 0;
%c2 = 0;
M = uo/co;
pbar = 101325;


k = ((gamma - 1)*2*lw*(tw-t)*sqrt(pi*lamda*cv*rhobar*dw*0.5*uo))/(s*co*pbar*sqrt(3));

ylag = z(:,1);
ddefun(1) = Y(2);
ddefun(2) = -a*a*pi*pi*Y(1) - (2*k*a*pi/gamma*M)*(sqrt(abs(1/3 + ylag*cos(1*pi*xf)))- sqrt(1/3))*sin(a*pi*xf);

history = [0.02;0;0.1;0;0.1;0;0;0;0;0;0;00;0;0;0;0;0;0;0;0];

for a = 1:10

sol(a) = dde23(ddefun,lags,history(a),tspan)


end

Steven Lord

unread,
Apr 22, 2014, 6:08:54 PM4/22/14
to

"Antony " <ashish...@gmail.com> wrote in message
news:lj6cub$3nu$1...@newscl01ah.mathworks.com...
Note that this says that DDEFUN is a _function handle_ not a vector.

*snip*

> ylag = z(:,1);
> ddefun(1) = Y(2);

If Y existed, this would make the first element of the ddefun vector be a
copy of the second element of that vector. But you want to specify DDEFUN as
a function handle to a function that accepts three inputs. See the DDEX1
function for an example of the correct way to call DDE23.

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Antony

unread,
Apr 23, 2014, 3:18:11 AM4/23/14
to
Thanks a lot Steve.

I have made the corrections and I have sent you an email too.
This is my code.

I have corrected the error in declaring the equations.
This is my code.

lags = 0.01 ;

tspan = [0,5];

history = [0.01; 0.02; 0.01; 0.01; 0.02; 0.01; 0.02; 0.01; 0.01; 0.02; 0.01; 0.02; 0.01; 0.01; 0.02; 0.01; 0.02; 0.01; 0.01; 0.02];

options = ddeset(options, 'InitialY',[0.02; 0 ; 0.1 ;0 ;0.1 ;0 ;0 ;0 ;0 ;0 ; 0 ;0 ;0 ;0; 0; 0; 0; 0; 0; 0]);



for a = 1:10

sol(a) = dde23(@trail2DDEfunctions,lags,history,tspan,options(a),a)

end

This is a function I have written separately.


function dde_rijketube = trail2DDEfunctions(t,y,Z,a)

% parameters
tw = 1000;
t = 295;
lw = 3.6;
gamma = 1.4;
lamda = 0.0328;
cv = 719;
dw = 0.0005;
rhobar = 1.205;
xf = 0.7;
uo = 0.3;
s = 0.0016;
co = 344.64;
%c1 = 0;
%c2 = 0;
M = uo/co;
pbar = 101325;


k = ((gamma - 1)*2*lw*(tw-t)*sqrt(pi*lamda*cv*rhobar*dw*0.5*uo))/(s*co*pbar*sqrt(3));

ylag1 = Z(1,1);
dde_rijketube(1) = y(2);
dde_rijketube(2) = -a*a*pi*pi*y(1) - (2*k*a*pi/gamma*M)*(sqrt(abs(1/3 + ylag1*cos(1*pi*xf)))- sqrt(1/3))*sin(a*pi*xf);

end

------------------------------------------
Still, errors continue.
Error using dde23 (line 222)
DDEs must return column vectors.

Error in trail2DDE (line 50)
sol(a) = dde23(@trail2DDEfunctions,lags,history,tspan,options(a),a)


"Steven Lord" <Steve...@mathworks.com> wrote in message <lj6pb4$9ba$1...@newscl01ah.mathworks.com>...

Steven Lord

unread,
Apr 23, 2014, 9:09:34 AM4/23/14
to

"Antony " <ashish...@gmail.com> wrote in message
news:lj7pfj$lef$1...@newscl01ah.mathworks.com...
> Thanks a lot Steve.
>
> I have made the corrections and I have sent you an email too.

Don't do that. Posting to the newsgroup is sufficient, and avoids potential
duplication of effort (either mine, if I'd responded to the email and then
seen this post, or mine and others if someone else had responded here before
I responded via email.)

> This is my code.

*snip*

> ------------------------------------------
> Still, errors continue. Error using dde23 (line 222)
> DDEs must return column vectors.
>
> Error in trail2DDE (line 50)
> sol(a) = dde23(@trail2DDEfunctions,lags,history,tspan,options(a),a)

Well, DOES trail2DDEfunctions return a column vector? According to the error
message, it does not. Make it return a column vector by defining
dde_rijketube to be a column vector then filling it in.

dde_rijketube = zeros(2, 1);
dde_rijketube(1) = ...

Antony

unread,
Apr 24, 2014, 11:58:09 AM4/24/14
to
Thanks Steve.

Clearly, these text-only posts are not sufficient to convey the entire problem.

"Antony " <ashish...@gmail.com> wrote in message <lj6cub$3nu$1...@newscl01ah.mathworks.com>...

Antony

unread,
Apr 24, 2014, 12:53:08 PM4/24/14
to
Hi once again,

Where would I look for the problem, when the error message is:

Subscripted assignment dimension mismatch.

Error in dde23>lagvals (line 674)
Z(:,j) = temp(:);

Error in dde23 (line 216)
Z0 = lagvals(t0,lags,history,t0,y0,[],varargin{:});

Thanks in advance!!! :D
"Antony " <ashish...@gmail.com> wrote in message <lj6cub$3nu$1...@newscl01ah.mathworks.com>...

Steven Lord

unread,
Apr 24, 2014, 12:58:02 PM4/24/14
to

"Antony " <ashish...@gmail.com> wrote in message
news:ljbfhk$pgo$1...@newscl01ah.mathworks.com...
> Hi once again,
>
> Where would I look for the problem, when the error message is:
>
> Subscripted assignment dimension mismatch.
>
> Error in dde23>lagvals (line 674)
> Z(:,j) = temp(:);
>
> Error in dde23 (line 216)
> Z0 = lagvals(t0,lags,history,t0,y0,[],varargin{:});
>
> Thanks in advance!!! :D

What is your history input? Is it one of:

>> % integrated from T0=TSPAN(1) to TF=TSPAN(end) where T0 < TF. The
>> solution % at t <= T0 is specified by HISTORY in one of three ways:
>> HISTORY can be % a function handle, where for a scalar T, HISTORY(T)
>> returns a column % vector y(t). If y(t) is constant, HISTORY can be
>> this column vector. % If this call to DDE23 continues a previous
>> integration to T0, HISTORY % can be the solution SOL from that call."

* A function handle that returns a column vector when given a scalar as
input
* A column vector (for a constant history)
* The SOL output from a previous call to DDE23

If not, make it one of those three.

*snip*
0 new messages