Error using FDE12
15 次查看(过去 30 天)
显示 更早的评论
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/996420/image.png)
2 个评论
KSSV
2022-5-13
You have not shown us function fde12 to check the error. Copy and paste that function here.
回答(1 个)
VBBV
2022-5-13
编辑:VBBV
2022-5-13
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 个评论
VBBV
2022-5-14
编辑:VBBV
2022-5-14
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio Processing Algorithm Design 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!