function splitEdge(this,iElement)

%   Author: A. Stothert 
%   Copyright 1986-2004 The MathWorks, Inc.
%   $Revision: 1.1.6.1 $ $Date: 2004/12/10 19:32:27 $

%Only split if have valid constraint
if ~this.isValid
   return
end

%If no split edge specified use selected edge
if nargin < 2, iElement = this.SelectedEdge; end

HostAx = handle(this.Parent);
%Set constraint x and y elments, check axis scale to find midpoint
switch lower(HostAx.Xscale)
   case 'log'
      xHalfPoint = log10(2);
   otherwise
      xHalfPoint = 0.5;
end
midX = (1-xHalfPoint)*this.xCoords(iElement,1) + xHalfPoint*this.xCoords(iElement,2);

%Temporarilty turn off any listeners 
set(this.Listeners,'Enable','off')

this.xCoords = [...
   this.xCoords(1:iElement-1,:); ...
   [this.xCoords(iElement,1), midX ]; ...
   [midX, this.xCoords(iElement,2)]; ...
   this.xCoords(iElement+1:end,:)];
switch lower(HostAx.Yscale)
   case 'log'
      yHalfPoint = log10(2);
   otherwise
      yHalfPoint = 0.5;
end
midY = (1-yHalfPoint)*this.yCoords(iElement,1) + yHalfPoint*this.yCoords(iElement,2);
this.yCoords = [...
   this.yCoords(1:iElement-1,:); ...
   [this.yCoords(iElement,1), midY ]; ...
   [midY, this.yCoords(iElement,2)]; ...
   this.yCoords(iElement+1:end,:)];

%Update Linked elements
this.Linked = [...
   this.Linked(1:iElement-1,:); ...
   [false, false]; ...
   this.Linked(iElement:end,:)];
%Update weight vector
this.Weight = [...
   this.Weight(1:iElement-1); ...
   this.Weight(iElement); ...
   this.Weight(iElement:end)];

%Turn any listeners back on
set(this.Listeners,'Enable','on')

%Call superclass update method to rerender
this.update;

