function updatechartable(view,h,varargin)

%% Updates the characteristic table in response to a ViewChange event.
%% varargin is the unit conversion factor if a unit conversion
%% is in progress.

if length(view.waves)==0
    return % Nothing to do
end

%% Intiailize vars
charTab = h.findtab('Characteristics');
charTable = charTab.Handles.CharTable;
newData = repmat({''},[charTable.getRowCount,charTable.getColumnCount]);
newData(:,1) = repmat({false},[size(newData,1) 1]);

%% Update newData cell array with char props
for row=1:charTable.getRowCount
    if ~isempty(view.waves(1).Characteristics)
        thischar = find(view.waves(1).Characteristics,'Identifier',...
            charTable.getValueAt(row-1,1));
        if ~isempty(thischar)
            if strcmp(thischar.Visible,'on') 
                newData{row,1} =  true;
            end
            % Convert to new units if this ViewChange event was the result
            % of a plot unit conversion
            if strcmp(view.AbsoluteTime,'off')
                if nargin>=3 
                    thischar.Data.StartTime = thischar.Data.StartTime*varargin{1};
                    thischar.Data.EndTime = thischar.Data.EndTime*varargin{1};
                end  
                newData(row,3:end) = {sprintf('%0.3g',thischar.Data.StartTime),sprintf('%0.3g',thischar.Data.EndTime)};
            else % Convert to absolute time
                startTimeStr = datestr(thischar.Data.StartTime*...
                    tsunitconv('days',view.TimeUnits)+datenum(view.StartDate),...
                    view.TimeFormat);
                endTimeStr = datestr(thischar.Data.EndTime*...
                    tsunitconv('days',view.TimeUnits)+datenum(view.StartDate),...
                    view.TimeFormat);
                newData(row,3:end) = {startTimeStr,endTimeStr};
            end
         end    
    end
end

%% Get the current data
charTableModel = charTable.getModel;
lastData = cell(size(newData));
for row=1:charTable.getModel.getDataVector.size
     lastData(row,:) = cell(charTable.getModel.getDataVector.get(row-1).toArray);
end

%% If the current data differs from the new data update the char table
%% non-recursively
for row=1:size(newData,1)
   for col=1:size(newData,2)
       if col~=2 && ~isequal(newData{row,col},lastData{row,col})
           charTableModel.MLsetValueAt(newData{row,col},row-1,col-1);
       end
   end
end