% plots a landscape with rivers
% define parameters
% centers of mountains
p = [-1, -1; 0, 1; 2, -1];
% heights of mountains
b = [20, 15, 12];
% sources of rivers
q = [-.7 -.9; .3 .7; 1.7 -1.005];
% domain width, D=[-a,a]^2
a=4;
% define grid
xy = linspace(-a,a,501);
[x,y] = meshgrid(xy);
hold on;
% plot landscape
h = 0;
for k=1:3;
d = (x-p(k,1)).^2 + (y-p(k,2)).^2;
h = h + b(k)*exp(-d);
end;
h = max(h,1);
contourf(x,y,h);
% plot rivers
[hx, hy] = gradient(h,xy,xy);
gh=streamline(x,y,-hx,-hy, q(:,1), q(:,2));
set(gh,'color',[0,0,1],'linewidth',4);
hold off;
|
automatisch erstellt
am 10. 5. 2007 |