Matlab:Gradual dimming population model: Difference between revisions
Jump to navigation
Jump to search
Homerun-chan (talk | contribs) mNo edit summary |
Homerun-chan (talk | contribs) mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 2: | Line 2: | ||
% | % | ||
% REFINED MAGICAL GIRL-WITCH POPULATION MODEL WITH DIMMING OVER TIME | % REFINED MAGICAL GIRL-WITCH POPULATION MODEL WITH DIMMING OVER TIME | ||
% This file has been produced for | % BASIC MAGICAL GIRL-WITCHES MODEL | ||
% | % This file has been produced for Matlab 7.4.0 | ||
% It is 100% compatible with FreeMat 4.0, however, you may want to change the plot commands to | |||
% plot(M, 'g.-') and plot(W, 'r.-') for aesthetics purpose | |||
% | % | ||
% This is the script that simulates the Refined Model, but with an | % This is the script that simulates the Refined Model, but with an | ||
Line 10: | Line 12: | ||
% If you want to modify the constants, please bear these restrictions in mind: | % If you want to modify the constants, please bear these restrictions in mind: | ||
% -C should be an integer | % -C should be an integer | ||
% -D, B, F, K, | % -D, B, F, K, and T should be values in [0,1] | ||
% -B should be greater than K (or else, the number of witches will be negative) | % -B should be greater than K (or else, the number of witches will be negative) | ||
% | % | ||
Line 19: | Line 21: | ||
F = 0.01; % Proportion of familiars becoming witches | F = 0.01; % Proportion of familiars becoming witches | ||
K = 0.165; % Proportion of witches getting killed by MSes | K = 0.165; % Proportion of witches getting killed by MSes | ||
T = 0.0001; % Number of MSes turning into witches over time | T = 0.0001; % Number of MSes turning into witches over time | ||
Line 28: | Line 29: | ||
for t=1:3000 | for t=1:3000 | ||
prop = | prop = min(M(t), W(t)); | ||
deltaM = C- prop*(D+B) - T*M(t); | deltaM = C- prop*(D+B) - T*M(t); | ||
deltaW = F*W(t) + prop*(B-K) + T*M(t); | deltaW = F*W(t) + prop*(B-K) + T*M(t); | ||
M(t+1)=M(t)+deltaM | M(t+1)=M(t)+deltaM; | ||
W(t+1)=W(t)+deltaW | W(t+1)=W(t)+deltaW; | ||
end | end | ||
Line 40: | Line 41: | ||
xlabel('time') | xlabel('time') | ||
ylabel('number of magical girls/witches') | ylabel('number of magical girls/witches') | ||
plot(M, 'g | plot(M, 'g-') | ||
plot(W, 'r | plot(W, 'r-') | ||
legend('Magical Girls', 'Witches', 'location', 'northeast') | legend('Magical Girls', 'Witches', 'location', 'northeast') | ||
legend('boxoff') | legend('boxoff') |
Latest revision as of 09:00, 21 May 2011
% % REFINED MAGICAL GIRL-WITCH POPULATION MODEL WITH DIMMING OVER TIME % BASIC MAGICAL GIRL-WITCHES MODEL % This file has been produced for Matlab 7.4.0 % It is 100% compatible with FreeMat 4.0, however, you may want to change the plot commands to % plot(M, 'g.-') and plot(W, 'r.-') for aesthetics purpose % % This is the script that simulates the Refined Model, but with an % additionnal effect of soul gems dimming over time. % % If you want to modify the constants, please bear these restrictions in mind: % -C should be an integer % -D, B, F, K, and T should be values in [0,1] % -B should be greater than K (or else, the number of witches will be negative) % C = 100; % Number of girls contracted by QBe D = 0.4; % Proportion of girls (who are fighting) that die B = 0.15; % Proportion of girls (who are fighting) to become witches F = 0.01; % Proportion of familiars becoming witches K = 0.165; % Proportion of witches getting killed by MSes T = 0.0001; % Number of MSes turning into witches over time M(1) = 0; % Number of magical girls at first W(1) = 0; % Number of witches at first hold on for t=1:3000 prop = min(M(t), W(t)); deltaM = C- prop*(D+B) - T*M(t); deltaW = F*W(t) + prop*(B-K) + T*M(t); M(t+1)=M(t)+deltaM; W(t+1)=W(t)+deltaW; end title('Evolution of the Magical Girls population over time') xlabel('time') ylabel('number of magical girls/witches') plot(M, 'g-') plot(W, 'r-') legend('Magical Girls', 'Witches', 'location', 'northeast') legend('boxoff') hold off