资源简介
基于malab,持续不断的有水滴滴下来,在平面上产生一圈一圈的波纹

代码片段和文件信息
function waterwave
n = 100;
g = 9.8;
dt = 0.02;
dx = 1.0;
dy = 1.0;
nplotstep = 8;
dropstep = 600;
D = drop(121);
[surfplot] = initial(n);
H = ones(n+2n+2); U = zeros(n+2n+2); V = zeros(n+2n+2);
Hx = zeros(n+1n+1); Ux = zeros(n+1n+1); Vx = zeros(n+1n+1);
Hy = zeros(n+1n+1); Uy = zeros(n+1n+1); Vy = zeros(n+1n+1);
nstep = 0;
while true
if mod(nstepdropstep) == 0
w = size(D1);
i = ceil(50)+(1:w);
j = ceil(50)+(1:w);
H(ij) = H(ij) + D;
end
nstep = nstep + 1;
i = 1:n+1;
j = 1:n;
Hx(ij) = (H(i+1j+1)+H(ij+1))/2 - dt/(2*dx)*(U(i+1j+1)-U(ij+1));
Ux(ij) = (U(i+1j+1)+U(ij+1))/2 - ...
dt/(2*dx)*((U(i+1j+1).^2./H(i+1j+1) + g/2*H(i+1j+1).^2) - ...
(U(ij+1).^2./H(ij+1) + g/2*H(ij+1).^2));
Vx(ij) = (V(i+1j+1)+V(ij+1))/2 - ...
dt/(2*dx)*((U(i+1j+1).*V(i+1j+1)./H(i+1j+1)) - ...
(U(ij+1).*V(ij+1)./H(ij+1)));
i = 1:n;
j = 1:n+1;
Hy(ij) = (H(i+1j+1)+H(i+1j))/2 - dt/(2*dy)*(V(i+1j+1)-V(i+1j));
Uy(ij) = (U(i+1j+1)+U(i+1j))/2 - ...
dt/(2*dy)*((V(i+1j+1).*U(i+1j+1)./H(i+1j+1)) - ...
(V(i+1j).*U(i+1j)./H(i+1j)));
Vy(ij) = (V(i+1j+1)+V(i+1j))/2 - ...
dt/(2*dy)*((V(i+1j+1).^2./H(i+1j+1) + g/2*H(i+1j+1).^2) - ...
(V(i+1j).^2./H(i+1j) + g/2*H(i+1j).^2));
i = 2:n+1;
j = 2:n+1;
H(ij) = H(ij) - (dt/dx)*(Ux(ij-1)-Ux(i-1j-1)) - ...
(dt/dy)*(Vy(i-1j)-Vy(i-1j-1));
U(ij) = U(ij) - (dt/dx)*((Ux(ij-1).^2./Hx(ij-1) + g/2*Hx(ij-1).^2) - ...
(Ux(i-1j-1).^2./Hx(i-1j-1) + g/2*Hx(i-1j-1).^2)) ...
- (dt/dy)*((Vy(i-1j).*Uy(i-1j)./Hy(i-1j)) - ...
(Vy(i-1j-1).*Uy(i-1j-1)./Hy(i-1j-1)));
V(ij) = V(ij) - (dt/dx)*((Ux(ij-1).*Vx(ij-1)./Hx(ij-1)) - ...
(Ux(i-1j-1).*Vx(i-1j-1)./Hx(i-1j-1))) ...
- (dt/dy)*((Vy(i-1j).^2./Hy(i-1j) + g/2*Hy(i-1j).^2) - ...
(Vy(i-1j-1).^2./Hy(i-1j-1) + g/2*Hy(i-1j-1).^2));
if mod(nstepnplotstep) == 0
C = abs(U(ij)) + abs(V(ij));
set(surfplot‘zdata‘H(ij)‘cdata‘C);
drawnow
end
if all(all(isnan(H))) break end
end
close(gcf);
% ------------------------------------
function D = drop(heightwidth)
[xy] = ndgrid(-1:(2/(width-1)):1);
D = height*exp(-5*(x.^2+y.^2));
% ------------------------------------
function [surfplot] = initial(n)
clf
shg
s
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3249 2012-10-26 01:01 waterwave.m
----------- --------- ---------- ----- ----
3249 1
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论