- #1
Avan
- 25
- 0
function RunlogisticOscilnumericalfisherfixedn0omega
omega=1;
N0=1;
k = 10;
A = 1;
p0 = 0.1;
tspan=(0:0.1:4);
[t,p] = ode45(@logisticOscilnumerical,tspan,p0,[],omega,k,N0);
figure(1)
plot(t,p)
xlabel('Time')
ylabel('p')
P = @(T) interp1(t,p,T);
f = @(t) ( ( A.*( ( N0.* (sin(omega.*t)).^2 .*(1-(2.*P(t)./k))+(omega.*cos(omega.*t) ) ).^2 ) ./( (N0.^2).*((sin(omega.*t)).^4).*((P(t)-(P(t).^2./k)).^2 )) ) ) ;
I1 = integral( f, 0,1,'ArrayValued',true)./1
I2 = integral( f, 0,2,'ArrayValued',true)./2
I3 = integral( f, 0,3,'ArrayValued',true)./3
I4 = integral( f, 0,4,'ArrayValued',true)./4
v = ( (N0.^2).*((sin(omega.*t)).^4).*((P(t)-(P(t).^2./k)).^2 ));
if (v < 1e-17)
f = 0
else
f = I4
end
I=[I1,I2,I3,I4] ;
T=[1,2,3,4] ;
figure(2)
plot(T,I)
title('The Fisher Information with time')
xlabel('Time')
ylabel('Fisher Information')
g = @(t) ( ( A.*( ( N0.* (sin(omega.*t)).^2 .*(1-(2.*P(t)./k))+(omega.*cos(omega.*t) ) ).^2 ) ./( (N0.^2).*((sin(omega.*t)).^4).*((P(t)-(P(t).^2./k)).^2 )) ) ) ;
figure(3)
plot(tspan,g(tspan))
xlabel('Time')
ylabel('The integrand')
1;
% function dpdt = logisticOscilnumerical(t,p,omega,k,N0)
% dpdt = N0*sin(omega*t)*p*(1-p/k);
% end
The problem as I understood from the code is with the term ( sin(omega*t)) in the denominator ,,I tried to put if statement to avoid singularity but it does not work,, any idea to solve this problem please??
omega=1;
N0=1;
k = 10;
A = 1;
p0 = 0.1;
tspan=(0:0.1:4);
[t,p] = ode45(@logisticOscilnumerical,tspan,p0,[],omega,k,N0);
figure(1)
plot(t,p)
xlabel('Time')
ylabel('p')
P = @(T) interp1(t,p,T);
f = @(t) ( ( A.*( ( N0.* (sin(omega.*t)).^2 .*(1-(2.*P(t)./k))+(omega.*cos(omega.*t) ) ).^2 ) ./( (N0.^2).*((sin(omega.*t)).^4).*((P(t)-(P(t).^2./k)).^2 )) ) ) ;
I1 = integral( f, 0,1,'ArrayValued',true)./1
I2 = integral( f, 0,2,'ArrayValued',true)./2
I3 = integral( f, 0,3,'ArrayValued',true)./3
I4 = integral( f, 0,4,'ArrayValued',true)./4
v = ( (N0.^2).*((sin(omega.*t)).^4).*((P(t)-(P(t).^2./k)).^2 ));
if (v < 1e-17)
f = 0
else
f = I4
end
I=[I1,I2,I3,I4] ;
T=[1,2,3,4] ;
figure(2)
plot(T,I)
title('The Fisher Information with time')
xlabel('Time')
ylabel('Fisher Information')
g = @(t) ( ( A.*( ( N0.* (sin(omega.*t)).^2 .*(1-(2.*P(t)./k))+(omega.*cos(omega.*t) ) ).^2 ) ./( (N0.^2).*((sin(omega.*t)).^4).*((P(t)-(P(t).^2./k)).^2 )) ) ) ;
figure(3)
plot(tspan,g(tspan))
xlabel('Time')
ylabel('The integrand')
1;
% function dpdt = logisticOscilnumerical(t,p,omega,k,N0)
% dpdt = N0*sin(omega*t)*p*(1-p/k);
% end
The problem as I understood from the code is with the term ( sin(omega*t)) in the denominator ,,I tried to put if statement to avoid singularity but it does not work,, any idea to solve this problem please??
Last edited: