实现了一下百度百科的内容:
https://baike.baidu.com/item/%E5%85%B0%E5%BD%BB%E6%96%AF%E7%89%B9%E6%96%B9%E7%A8%8B/9761321
MATALB代码如下:
% Lanchest方程平方律仿真
clear;clc;close all;
% blue = zeros(1,10); % 蓝军兵力
blue(1,1) = 1000;
% red = zeros(1,10); % 红军兵力
red(1,1) = 1000;
yita = 1; % 作战效率
round = 1; % 回合数
while red(1,round) > 10
blue(1,round+1) = sqrt(blue(1,round)^2 - (red(1,round)/2)^2);
red(1,round+1) = red(1,round)/2;
round = round + 1;
end
% 画图
t = 1:round;
figure(1);
plot(t,blue,'-b^','MarkerFaceColor','b');hold on;
plot(t,red,'-ro','MarkerFaceColor','r');hold on;
ylabel('战斗力');xlabel('时间/回合');
legend('我方','敌方');
结果如下图所示。
和图片里面描述的情况一致。