function velocity_arrows2 ( xyuv_file, scale ) %% VELOCITY_ARROWS2 makes an arrow plot of a velocity field. % % Discussion: % % The data is stored in one files, XY coordinates, and velocity values. The % files is in the "TABLE" format. % % In particular, each line of the file should contain the X and Y coordinates % and U, V velocity components for a single point. Comment lines may be included % if they begin with the special symbol "#". % % Modified: % % 18 November 2005 % % Author: % % John Burkardt % % Parameters: % % Input, character XYUV_FILE, the name of the data file. % % Input, real SCALE, a scale factor. % fprintf ( 1, '\n' ); fprintf ( 1, 'VELOCITY_ARROWS2:\n' ); fprintf ( 1, ' Arrow plots of a velocity field.\n' ); if ( nargin < 1 ) fprintf ( 1, '\n' ); xyuv_file = input ( 'Enter the data file, such as ''xyuv.txt'': ' ); end xyuv = load ( xyuv_file ); x = xyuv(:,1); y = xyuv(:,2); if ( nargin < 2 ) fprintf ( 1, '\n' ); scale = input ( ... 'Enter a scale factor for the velocities (1.0 for no magnification): ' ); end u = xyuv(:,3); v = xyuv(:,4); quiver ( x, y, u, v, scale, 'b' ); axis equal hold on k = convhull ( x, y ); plot ( x(k), y(k), 'r' ); hold on % % Plot an invisible frame. This will help to force all the plots to % be the same size. % x_min = min ( x ); x_max = max ( x ); y_min = min ( y ); y_max = max ( y ); delta = 0.05 * max ( x_max - x_min, y_max - y_min ); plot ( [ x_min - delta, ... x_max + delta, ... x_max + delta, ... x_min - delta, ... x_min - delta ], ... [ y_min - delta, ... y_min - delta, ... y_max + delta, ... y_max + delta, ... y_min - delta ], ... 'w' ); hold off