function more_points = expand(data) %------------------------------------------------------------------------------------------ %****************************** PROGRAM EXPLANATION EXPAND.m ****************************** % EXPAND.m expands a data set containing (x,y,z) points describing the location of cave % survey stations and the four cross-sectional points describing the walls, floor, and % ceiling at each station. Nine new points are generated between each of the five % surveyed points at consecutive stations through linear interpolation. % EXPAND.m is a subroutine of CAVEMAP but can also be run independently. % Input to Expand.m must consist of a matrix of n rows and 11 columns ordered as: % [ss x y z ztop zbot room xrtw yrtw xltw yltw] which is the output data from CONVERT.m. % Output from EXPAND.m consists of a two-dimensional map of the cave system described by % the input data and the data file containing the (x,y) points describing the outermost % perimeter of the cave system = expwall.txt. %------------------------------------------------------------------------------------------ %******************* DETERMINING SIZE OF THE INPUT DATA MATRIX **************************** [row,col] = size(data); %------------------------------------------------------------------------------------------ %************************* EXTRACTING DATA FROM INPUT MATRIX ****************************** ss = data(:,1); x = data(:,2); y = data(:,3); z = data(:,4); ztop = data(:,5); zbot = data(:,6); room = data(:,7); xrtw = data(:,8); yrtw = data(:,9); xltw = data(:,10); yltw = data(:,11); %------------------------------------------------------------------------------------------ %***************************** ADDING MARKERS IF NEEDED *********************************** if ss(row) ~= -999.9 row = row + 1; ss(row) = -999.9; x(row) = -999.9; y(row) = -999.9; z(row) = -999.9; ztop(row) = -999.9; zbot(row) = -999.9; room(row) = -999.9; xrtw(row) = -999.9; yrtw(row) = -999.9; xltw(row) = -999.9; yltw(row) = -999.9; end %------------------------------------------------------------------------------------------ %********************** LOOPING OVER ALL INPUT SURVEY STATIONS **************************** % count is an index that will tally all new points count = 1; num = 1; ssmark = 0; % stopping at row-1 so the program will not generate new points past the last survey % station. for i = 1:row-1 if x(i) ~= -999.9 if x(i+1) ~= -999.9 xinc(i) = (x(i+1) - x(i)) / 10; yinc(i) = (y(i+1) - y(i)) / 10; zinc(i) = (z(i+1) - z(i)) / 10; xrtwinc(i) = (xrtw(i+1) - xrtw(i)) / 10; xltwinc(i) = (xltw(i+1) - xltw(i)) / 10; yrtwinc(i) = (yrtw(i+1) - yrtw(i)) / 10; yltwinc(i) = (yltw(i+1) - yltw(i)) / 10; ztopinc(i) = (ztop(i+1) - ztop(i)) / 10; zbotinc(i) = (zbot(i+1) - zbot(i)) / 10; x_new(count) = x(i); y_new(count) = y(i); z_new(count) = z(i); xrtw_new(count) = xrtw(i); xltw_new(count) = xltw(i); yrtw_new(count) = yrtw(i); yltw_new(count) = yltw(i); ztop_new(count) = ztop(i); zbot_new(count) = zbot(i); room_new(count) = room(i); count = count + 1; new_ss(num) = num - ssmark; num = num + 1; for j = 1:9 x_new(count) = x_new(count-1) + xinc(i); y_new(count) = y_new(count-1) + yinc(i); z_new(count) = z_new(count-1) + zinc(i); xrtw_new(count) = xrtw_new(count-1) + xrtwinc(i); xltw_new(count) = xltw_new(count-1) + xltwinc(i); yrtw_new(count) = yrtw_new(count-1) + yrtwinc(i); yltw_new(count) = yltw_new(count-1) + yltwinc(i); ztop_new(count) = ztop_new(count-1) + ztopinc(i); zbot_new(count) = zbot_new(count-1) + zbotinc(i); room_new(count) = room(i); count = count + 1; new_ss(num) = num - ssmark; num = num + 1; end else new_ss(num) = num - ssmark; num = num + 1; ssmark = ssmark + 1; new_ss(num) = -999.9; num = num + 1; %------------------------------------------------------------------------------------------ %**************** ASSIGNING THE LAST NEW POINT = TO ORIGINAL LAST POINT ******************* x_new(count) = x(i); y_new(count) = y(i); z_new(count) = z(i); xrtw_new(count) = xrtw(i); xltw_new(count) = xltw(i); yrtw_new(count) = yrtw(i); yltw_new(count) = yltw(i); ztop_new(count) = ztop(i); zbot_new(count) = zbot(i); room_new(count) = room(i); count = count + 1; x_new(count) = -999.9; y_new(count) = -999.9; z_new(count) = -999.9; xrtw_new(count) = -999.9; yrtw_new(count) = -999.9; xltw_new(count) = -999.9; yltw_new(count) = -999.9; ztop_new(count) = -999.9; zbot_new(count) = -999.9; room_new(count) = -999.9; count = count + 1; end end end %------------------------------------------------------------------------------------------ %************************** ESTABLISHING THE OUTPUT DATA SET ****************************** more_points = [new_ss' x_new' y_new' z_new' ztop_new' zbot_new' room_new' xrtw_new' yrtw_new' xltw_new' yltw_new']; %------------------------------------------------------------------------------------------ %********************************* EXTRACTING WALL POINTS ********************************* % creating the output file containing (x,y) points describing the outermost perimeter of % cave system. wallptsr = more_points(:,8:9); wallptsl = more_points(:,10:11); wallpts = [wallptsr' wallptsl']'; [new_row,new_col] = size(wallpts); wallpoints = [0 0]'; wallct = 0; for i = 1:new_row if wallpts(i,1) ~= -999.9 wallpoints = [wallpoints wallpts(i,1:2)']; wallct = wallct + 1; end end wallpoints = wallpoints(:,2:wallct)'; %------------------------------------------------------------------------------------------ %***************************** PLOTTING EXPANDED DATA ************************************* plotter2(more_points) %------------------------------------------------------------------------------------------ %************************************ SAVING DATA ***************************************** save expdata.txt more_points -ascii -tabs % this is the file containing the outermost perimeter data save expwall.txt wallpoints -ascii -tabs %------------------------------------------------------------------------------------------ %********************* CALLING PERIM.m TO CREATE PERIMETER POINTS ************************* disp(' ') disp(' The expanded data set has been saved in the current') disp(' directory as expdata.txt.') disp(' ') disp(' ') disp(' If there are no crosses in the transect lines between') disp(' consecutive wall point pairs then you may proceed with') disp(' adding perimeter points. Otherwise print out the data') disp(' points and pick new point pairs. ') disp(' ') disp(' ') disp(' Do you wish to proceed with the program or quit the program') disp(' to build a new data set? - - - [P]roceed / P[r]int') disp(' ') disp(' ') proceedchk = input(' Enter your choice [P / r] ','s'); if isempty(proceedchk) proceedchk = 'P'; end if proceedchk == 'p' proceedchk = 'P'; end if proceedchk == 'P' perdata = perim(more_points); end %------------------------------------------------------------------------------------------ %****************************** END OF PROGRAM EXPAND.m ***********************************