function write_node_k_file(k_file_to_write, nodal_matrix)
% Writes the nodal coordinates on LS-Dyna format to a file.
% Special handing of the final row to ensure that no blank line is
% inserted, as is the case when using dlmwrite.
%
% INPUTS: 	k_file_to_write 	- String, name of file to create.
%           nodal_matrix 		- [n x 4] matrix with nodal ID and x, y, z coordinate.
%
%
% created by: ABR
% date : 2024-04-18
fileID = fopen(k_file_to_write,'w');
fprintf(fileID, '%s\n','*NODE')
fprintf(fileID, '%8d%16.6f%16.6f%16.6f\n',nodal_matrix(1:end-1,:)')
fprintf(fileID, '%8d%16.6f%16.6f%16.6f',nodal_matrix(end,:)')
fclose(fileID);
