Error using FDE12
32 views (last 30 days)
Show older comments
I am trying to solve a SERID mathematical model with matlab.
This involves the freactional derivatives. In order to solve these equation I tried to run the code using fde12.
But, there are errors and I dont know what to do.
Any support or help is appreciated.
function [time,state_values]= mathematical1
%%Initial values
t0 = 0;
tend = 100;
%tspan=[t0,tend];
y0 = [100,10,3,0,0];
%%Constant(rates) values
A=0; % Migrated Population into the considered community
e=0.3; % Contact rate between S and E
a=0.4; % Contact rate between S and I
g=0.23; % Recovery rate
k=0.3; % Rate of Exposed to Infected
p=0.25; % Exposed to Recovery
m=0.12; % Death rate from Infected
b=0.45; % Recovery rate recovered from disease and alive
%% [sdot] = g(t,s)
sdot = @(t,s)[A-(e*s(1)*s(2))-(a*s(1)*s(3))+(g*s(4));
-((k+p)*s(2))+(e*s(1)*s(2))+(a*s(1)*s(3));......
-((b+m)*s(3))+(k*s(2));
-(g*s(4))+(p*s(2))+(b*s(3));
(m*s(3))];
h = 2^(-6);
alpha= 0.8;
[time, state_values] = fde12(alpha, sdot, t0,tend,y0,h);
%%Extracting individual values
S= state_values(:,1);
E= state_values(:,2);
I= state_values(:,3);
R= state_values(:,4);
D= state_values(:,5);
%%Plot S,E,I,R,D
figure(1)
clf
plot(time,S); title('Susceptible Population vs Time')
figure(2)
clf
plot(time,E); title('Exposed Population vs Time')
figure(3)
clf
plot(time,I); title('Infected Population vs Time')
figure(4)
clf
plot(time,R); title('Recovered Population vs Time')
figure(5)
clf
plot(time,D); title('Death Population vs Time')
end
ERRORS:
2 Comments
KSSV
on 13 May 2022
You have not shown us function fde12 to check the error. Copy and paste that function here.
Answers (1)
VBBV
on 13 May 2022
Edited: VBBV
on 13 May 2022
s = 1:4; % define s vector passed as argument to function line below e.g. values
sdot = @(t,s)[A-(e*s(1)*s(2))-(a*s(1)*s(3))+(g*s(4));
-((k+p)*s(2))+(e*s(1)*s(2))+(a*s(1)*s(3));......
-((b+m)*s(3))+(k*s(2));
-(g*s(4))+(p*s(2))+(b*s(3));
(m*s(3))];
[time, state_values] = fde12(alpha, sdot, t0,tend,y0,h); % function
Define the s vector before passing anonymous function sdot as argument to fde12
3 Comments
VBBV
on 14 May 2022
Edited: VBBV
on 14 May 2022
t0 = 0;
tend = 100;
%tspan=[t0,tend];
y0 = [100,10,3,0,0];
%%Constant(rates) values
A=0; % Migrated Population into the considered community
e=0.3; % Contact rate between S and E
a=0.4; % Contact rate between S and I
g=0.23; % Recovery rate
k=0.3; % Rate of Exposed to Infected
p=0.25; % Exposed to Recovery
m=0.12; % Death rate from Infected
b=0.45; % Recovery rate recovered from disease and alive
s = 1:4 % define the values for s here
%% [sdot] = g(t,s)
sdot = @(s)[A-(e*s(1)*s(2))-(a*s(1)*s(3))+(g*s(4));
-((k+p)*s(2))+(e*s(1)*s(2))+(a*s(1)*s(3));......
-((b+m)*s(3))+(k*s(2));
-(g*s(4))+(p*s(2))+(b*s(3));
(m*s(3))]; % change
It seems, sdot is not a function of t . The time, t is used as t0 , a seperate argument inside the callinig functions.
See Also
Categories
Find more on Audio Processing Algorithm Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!