function port(varargin)
%PORT  Draw a port

%   Author(s): A. DiVergilio
%   Copyright 1986-2002 The MathWorks, Inc.
%   $Revision: 1.6 $  $Date: 2002/04/10 06:41:30 $

%---Default properties
p = struct(...
   'Parent',[],...
   'XData',[1 1],...
   'YData',[1 2],...
   'LineStyle','none',...
   'LineWidth',2,...
   'Color','k',...
   'Marker','o',...
   'MarkerSize',6,...
   'MarkerFaceColor','w',...
   'FontSize',10,...
   'FontWeight','bold',...
   'Name','V',...
   'Tag','',...
   'Clipping','off');
plist = fieldnames(p);

%---Merge user-specified properties
for i=1:2:nargin-1
   Property = pnmatch(varargin{i},plist);
   Value = varargin{i+1};
   p.(Property) = Value;
end
if isempty(p.Parent), p.Parent = gca; end

%---Draw a line
line(...
   'Parent',p.Parent,...
   'XData',p.XData,...
   'YData',p.YData,...
   'LineStyle',p.LineStyle,...
   'LineWidth',p.LineWidth,...
   'Color',p.Color,...
   'Marker',p.Marker,...
   'MarkerSize',p.MarkerSize,...
   'MarkerFaceColor',p.MarkerFaceColor,...
   'Tag',p.Tag,...
   'Clipping',p.Clipping);

%---Port label
[ymax,idx] = max(p.YData);
xmax = p.XData(idx);
text(...
   'Parent',p.Parent,...
   'Units','data',...
   'String',p.Name,...
   'Position',[xmax ymax+.06],...
   'FontSize',p.FontSize,...
   'FontWeight',p.FontWeight,...
   'HorizontalAlignment','center',...
   'VerticalAlignment','bottom',...
   'Tag',p.Tag,...
   'Clipping',p.Clipping);
