How to use the Dirac Delta Function in ode45?

Hello, I am trying to use matlab to plot the phase plane of an equation. I have written the correct equation in the code, but for some reason I have received errors.
Can someone please take a look?
This runs the function 'radio2'
[t radiot1] = ode45('radio2', [0:0.01:20], [.6 ;.4]);
plot(radiot1(:,2),radiot1(:,1))
'radio 2' is defined as
function dz = radio2(t, cancer)
a=1;
b=1;
c=3;
d=1;
e=2;
f=2;
D=2;
T=1.3502;
alphax=.33;
betax=.02;
alphay=.06;
betay=.02;
syms j
x=cancer(1);
y=cancer(2);
dxdt = a*x - b*x^2 - c*x*y-x*symsum((alphax*D+betax*D^2)*dirac(t-j*T),j);
dydt = d*y - e*y^2 - f*x*y-y*symsum((alphay*D+betay*D^2)*dirac(t-j*T),j);
dz = [dxdt; dydt;];
I receive the following errors

댓글 수: 1

Walter Roberson
Walter Roberson 2011년 12월 16일
The error didn't show up. If you need to upload it as an image, please see http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2011년 12월 16일

0 개 추천

Your radio2() is going to be trying to return a symbolic object, which ode45 is not going to be able to process.
symsum() returns a symbolic object, even if the output is numeric. Use double() on the symsum() to convert numeric symbolic objects to double precision.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

질문:

2011년 12월 16일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by