function velocity6_write ( file_name, node_num, node_u_variable, ... node_v_variable, variable_num, node_c ) %% VELOCITY6_WRITE writes the velocities to a file. % % Modified: % % 06 September 2006 % % Author: % % John Burkardt % % Parameters: % % Input, character FILE_NAME, the file name. % % Input, integer NODE_NUM, the number of nodes. % % Input, integer NODE_U_VARIABLE(NODE_NUM), NODE_V_VARIABLE(NODE_NUM), % the indices of the horizontal and vertical velocity variables % associated with the node, or -1 if there is none. % % Input, integer VARIABLE_NUM, the number of variables. % % Input, real NODE_C(NODE_NUM), the coefficients of the solution. % output_unit = fopen ( file_name, 'wt' ); if ( output_unit < 0 ) fprintf ( 1, '\n' ); fprintf ( 1, 'VELOCITY6_WRITE - Warning!\n' ); fprintf ( 1, ' Could not write the velocity file.\n' ); return end for node = 1 : node_num u_index = node_u_variable(node); if ( 0 < u_index ) u = node_c(u_index); else u = 0.0; end v_index = node_v_variable(node); if ( 0 < v_index ) v = node_c(v_index); else v = 0.0; end fprintf ( output_unit, ' %14f %14f\n', u, v ); end fclose ( output_unit );