Skip to content

Instantly share code, notes, and snippets.

@samstewart
Created October 6, 2016 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samstewart/7a35ac582f30ae8501e6f3eba55c04e2 to your computer and use it in GitHub Desktop.
Save samstewart/7a35ac582f30ae8501e6f3eba55c04e2 to your computer and use it in GitHub Desktop.
Plot a 3D array representing a vector field
% plots a 3D array representing a vector field in grid coordinates (1, 1),
% (1, 2), etc.
function plot_vector_field(field)
N = size(field, 1);
M = size(field, 2);
[x,y] = meshgrid(1:1:N, 1:1:M)
u = field(:, :, 1);
v = field(:, :, 2);
quiver(x,y,u,v);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment