数学建模美赛集训的时候要用到一个海面模拟,分享一下海面模拟的MATLAB代码
先贴一下结果图:
下面是源代码~~~
function waterwave
n = 64; % grid size
g = 9.8; % gravitational constant
dt = 0.01; % hardwired timestep
dx = 1.0;
dy = 1.0;
nplotstep = 8; % plot interval
ndrops = 5; % maximum number of drops
dropstep = 500; % drop interval
D = droplet(1.5,21); % simulate a water drop
% Initialize graphics
[surfplot,top,start,stop] = initgraphics(n);
% Outer loop, restarts.
while get(stop,'value') == 0
set(start,'value',0)
H = ones(n+2,n+2); U = zeros(n+2,n+2); V = zeros(n+2,n