My Graph isn't displaying

1 view (last 30 days)
Musa Abdullahi
Musa Abdullahi on 31 Jan 2023
Commented: Musa Abdullahi on 1 Feb 2023
i am trying to plot my graph. the code does not show any error, but the graph is not displying..
%function Modified
lags = 0.2;
tspan = [0,10];
sol = dde23(@ddehs, lags, @hshist, tspan);
time = sol.x;
S = sol.y(1,:);
I = sol.y(2,:);
V = sol.y(3,:);
T = sol.y(4,:);
R = sol.y(5,:);
hold on
plot(time,I,'b')
plot(time,S,'r')
plot(time,V,'g')
plot(time,T,'k')
plot(time,R,'y')
xlabel('Time (Years)');
legend('S_h','I_h','V_h','T_h','R_h')
hold off
%end
function dydt = ddehs(~,y,z)
Lh = 10000; muh = 0.06;
uh = 0.09; Bh = 0.5;
mud = 0.08; tau = 0.2;
ah = 1; mh = 0.2; bh =0.5; rh = 0.5;
dh = 0.21;
ylag1 = z(2,1);
dydt = [ Lh - Bh*y(1)*ylag1*exp(-mud*tau)-(muh + uh)*y(1) + bh*y(3) + dh*y(5)
Bh*y(1)*ylag1*exp(-mud*tau) - (muh + mh + ah)*y(2)
uh*y(1) - (bh + muh)*y(3)
ah*y(2) - (muh + rh)*y(4)
rh*y(4) - (muh + dh)*y(5) ];
end
function s = hshist(~)
s = ones(5,1);
end
  2 Comments
Torsten
Torsten on 31 Jan 2023
I reduced tspan to [0 10], set s = ones(5,1); instead of s = ones(3,1); and changed muH to muh in one position in the definition of dydt.
Musa Abdullahi
Musa Abdullahi on 1 Feb 2023
Thank you.. You have been of great help to me.. Thank you once again

Sign in to comment.

Answers (0)

Categories

Find more on Introduction to Installation and Licensing 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!