function rmaxes(h,pos)

%% Removes axes at the specified position

%% Check that there are enough axes to remove
if length(h.ChannelName)<2
    errordlg('The number of axes cannot be reduced to zero',...
        'Time Series Tool','modal')
    return
end

%% Check that the axes to be removed are empty
for k=1:length(h.Waves)
    if any(h.Waves(k).RowIndex == pos)
         ButtonName = questdlg(sprintf('Selected axes contain %s. Continue?', ...
             h.Waves(k).DataSrc.Timeseries.Name), ...
                       'Time Series Tool', ...
                       'OK','Cancel','Cancel');
         if strcmp(ButtonName,'Cancel')
             return
         end
         % Remove wave
         h.rmwave(h.Waves(k));
    end
end

%% Define the new channel names 
newChannelName = h.ChannelName;
newChannelName(pos) = [];

%% Resize the grid
h.resize(newChannelName);


%% Announce the change to the axestable listenrs
h.AxesGrid.send('viewchanged')
