# Visualization of vector fields in a solid

Saltar a: navegación, buscar

We show how to visualize vector fields on plane regions, representing solids, with Octave UPM. We focus on the example in Dibujar un sólido 2-D, i.e. the rectangle $[-1/2,1/2]\times [0,2]$ and the vector field $f(x,y)=x\vec i + y \vec j$. We follow the steps:

1. We introduce a sampling of the two segments with a suitable step
2. With meshgrid command we define two matrixes with the x and y coordinates of the mesh points
3. Compute the two components of the vector field in the grid points.
4. We use the quiver command to draw the field and adjust the axis. We see the picture from the top.

## 1 MATLAB code

1 x=-0.5:0.1:0.5;       % sampling of the interval [-1/2,1/2]
2 y=0:0.1:2;            % sampling of the interval [0,2]
3 [xx,yy]=meshgrid(x,y); % matrixes of x and y coordinates
4 figure(1)
5 fx=xx;                 % x-component of the vector field
6 fy=yy;                 % y-component of the vector field
7 quiver(xx,yy,fx,fy)     % Draw the vector field
8 axis([-2,2,-1,3])      % select region for drawing
9 view(2)                % See the pisture from the top