
[x, y, z] = meshgrid (-2:0.1:2, -1:0.1:1, -1:0.1:1);
u = 2 + 8 * exp (-2.0*x.*x);
v = zeros (size (x));
w = zeros (size (x));
[sx, sy, sz] = meshgrid (-2, -1:0.5:1, -1:0.5:1);

figure ("units", "normalized", "position", [0.1 0.1 0.8 0.4]);

subplot (1, 2, 1);
hold on;
streamtube (x, y, z, u, v, w, -2, 0, 0, [3, 60]);
colormap (jet);
quiver3 (x, y, z, u, v, w);
shading interp;
view ([-47, 24]);
camlight ();
lighting gouraud;
view (3);
grid on;
axis tight equal;
title ("divergence plot");
h = colorbar;
title (h, "height");
h = streamline (x, y, z, u, v, w, sx, sy, sz, 1);
set (h, "color", "r");
scatter3 (sx(:), sy(:), sz(:), 20, "filled", "o", "markerfacecolor", "r");

subplot (1, 2, 2);
hold on;
ostreamtube (x, y, z, u, v, w, -2, 0, 0, [3, 60]);
colormap (jet);
quiver3 (x, y, z, u, v, w);
shading interp;
view ([-47, 24]);
camlight ();
lighting gouraud;
view (3);
grid on;
axis tight equal;
title ("classic streamtube");
h = colorbar;
title (h, "speed");
h = streamline (x, y, z, u, v, w, sx, sy, sz, 1);
set (h, "color", "r");
scatter3 (sx(:), sy(:), sz(:), 20, "filled", "o", "markerfacecolor", "r");

