MATLAB模型:SIR模型 - 感染人数模拟
function i = model1(lambda, i0, days) i = zeros(days, 1); % initialize the vector of infected people
i(1) = i0; % set the initial number of infected people
for t = 2:days
i(t) = lambda * i(t-1); % calculate the number of infected people at time t
end
end
% Example usage: lambda = 1.2; % number of effective contacts per day i0 = 10; % initial number of infected people days = 7; % number of days to simulate
result = model1(lambda, i0, days); % run the model
% Plot the results figure; plot(1:days, result, 'o-'); xlabel('Day'); ylabel('Number of Infected People'); title('Model 1: Number of Infected People over Time');
原文地址: https://www.cveoy.top/t/topic/pBX1 著作权归作者所有。请勿转载和采集!