% 07/2008 % Started by J Ramon Arrowsmith % Modified by David E. Haddad % This script is designed to clean a dataset by loading a multi-column matrix from an % existing text file and exporting two 3-column text files (one for ArcMap with a % header, and another for P2G without a header). % IMPORTANT NOTE: You cannot use MATLAB's "load" command if your original data text % file has a header. MAKE SURE YOU DELETE THE HEADER! % Here we go... clear all % CHANGE THIS TO YOUR FILE'S NAME xyz_data = load('input_filename.txt'); x = xyz_data(:,1); y = xyz_data(:,2); z = xyz_data(:,3); B = [x y z]; % new 3-column matrix % for P2G (doesn't need headers): dlmwrite('xyz_P2G.txt',B); % comma delimited % for ArcMap (needs headers!!): fid = fopen('xyz_ArcMap.txt','w+t'); fprintf(fid,'x,y,z\n',B); % writes headers to text file fclose(fid); dlmwrite('xyz_ArcMap.txt',B,'-append'); % comma delimited, appends new xyz matrix to text file