function [ages] = age_map_meandering(meandering_grid,grid_height, grid_width,starting_iteration,rework_time,dt_yrs)
% map the age of an untouched piece of floodplain
% Set up age grid
grid_length = rework_time;
ages(grid_length).map = [];
for ii = 1:grid_length
ages(ii).map = NaN(grid_height, grid_width);
end
position = starting_iteration;
% loops through iteration to create age maps for each time step
for iteration = 1:(rework_time-1)
% Makes intermediary age_map that we can age all grid cells evenly
% (as to not build up NaN values)
if iteration > 1
[row,col] = find(ages(iteration-1).map==0);
length_row = length(row);
int_map = ages(iteration-1).map;
for ii = 1: length_row
int_map(row(ii),col(ii)) = 0;
end
end
% ages all floodplains by 1
if iteration == 1
ages(iteration).map = ages(iteration).map;
else
ages(iteration).map = int_map(:,:) + 1;
end
% overprints where the channel is by resetting counter to zero
[row,col] = find(meandering_grid(position).map==1);
length_row = length(row);
for ii = 1: length_row
ages(iteration).map(row(ii),col(ii)) = 0;
end
position = position + 1;
end
end