⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sourcesinkplot.m

📁 数值方法和MATLAB实现与应用.zip
💻 M
字号:
% sourceSinkPlot  Surface and contour plots of source/sink pair

ngrid = 40;                      %  Number of grid lines
xg = linspace(-5,5,ngrid);       %  Vector of both x and y grid locations
[X,Y] = meshgrid(xg,xg);         %  Prepare for vectorized R calculations

gam = 10;                        %  Strength of the source and sink
a = 1.5;                         %  Distance from origin to source/sink
Rsi   = sqrt( (X+a).^2 + Y.^2 );           %  Distance from sink
Rso = sqrt( (X-a).^2 + Y.^2 );             %  Distance from source
phi = (gam/(2*pi))*(log(Rsi) - log(Rso));  %  Potential function

subplot(2,1,1)                   %  First subplot for surface plot
surf(X,Y,phi)                    %  Create surface plot
view(-20,15)                     %  Adjust the viewing angle

subplot(2,1,2)                   %  Second surface plot for contours
levels = -3:3;                   %  Contour levels to be drawn
cs = contour(xg,xg,phi,levels);  %  Create contours
clabel(cs,levels);               %  and label them

colormap('gray')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -