29.11.2014 Views

Advanced Plotting and Model Building - FET

Advanced Plotting and Model Building - FET

Advanced Plotting and Model Building - FET

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Visualizing vector fields<br />

The function quiver draws little arrows to indicate a gradient<br />

or other vector field. Although it produces a 2-D plot, it’s<br />

often used in conjunction with contour. As an example,<br />

consider the scalar function of two variables<br />

V = x 2 + y. The gradient of V is defined as the vector field<br />

∇V = ( ∂V / ∂x , ∂V / ∂y ) = (2x, 1).<br />

The following statements draw arrows indicating the<br />

direction of ∇V at points in the x-y plane (see the next figure).<br />

[x y] = meshgrid(-2:.2:2, -2:.2:2);<br />

V = x.^2 + y;<br />

dx = 2*x;<br />

dy = dx; % dy same size as dx<br />

dy(:,:) = 1; % now dy is same size as dx but all 1’s<br />

contour(x, y, V), hold on<br />

quiver(x, y, dx, dy), hold off<br />

5-68<br />

Z.R.K

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!