fig=createmadfig('epd'); 
fig=createmadloadmenu(fig);
fig=createmadmenus(fig);
 
ud.signalAxes = axes('Parent',fig, ...
	'Box','on', ...
	'ButtonDownFcn','timedom playSignal', ...
	'Position',[0.08 0.68 0.71 0.26], ...
	'YLim',[-1.1 1.1], ...
	'YLimMode','manual');
  
ud.signalLine = line('Parent',ud.signalAxes, ...
	'ButtonDownFcn','epd playSignal', ...
	'Color',[0 0 1], ...
	'XData',[], ...
	'YData',[]);
  
ud.signalUserLC = line('Parent',ud.signalAxes, ...
	'ButtonDownFcn','epd left', ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'XData',[], ...
	'YData',[]);
  
ud.signalUserRC = line('Parent',ud.signalAxes, ...
	'ButtonDownFcn','epd right', ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'XData',[], ...
	'YData',[]);
  
ud.signalAutoLC = line('Parent',ud.signalAxes, ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'XData',[], ...
	'YData',[]);
ud.signalAutoRC  = line('Parent',ud.signalAxes, ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'XData',[], ...
	'YData',[]);

  ylabel('Signal');


ud.energyAxes = axes('Parent',fig, ...
	'Box','on', ...
	'Position',[0.08 0.33 0.71 0.26], ...
	'XTick',[0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0], ...
	'XTickLabelMode','manual', ...
	'XTickMode','manual', ...
	'YLim',[0 1.1], ...
	'YLimMode','manual');

ud.energyLine = line('Parent',ud.energyAxes, ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'XData',[], ...
	'YData',[]);
ud.ITULine = line('Parent',ud.energyAxes, ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'XData',[], ...
	'YData',[]);
ud.ITLLine = line('Parent',ud.energyAxes, ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'XData',[], ...
	'YData',[]);

ylabel('Energy');     

ud.zcAxes = axes('Parent',fig, ...
	'Box','on', ...
	'Position',[0.08 0.034 0.71 0.26], ...
	'XTick',[0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0], ...
	'XTickLabelMode','manual', ...
	'XTickMode','manual', ...
	'YLim',[0 1.1], ...
	'YLimMode','manual');
  
ud.zcLine = line('Parent',ud.zcAxes, ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'XData',[], ...
	'YData',[]);

  ud.IZCTLine = line('Parent',ud.zcAxes, ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'XData',[], ...
	'YData',[]);

  ylabel('ZC Rate');

ud.cursorToggle = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'Callback','epd showEnds', ...
	'ListboxTop',0, ...
	'Position',[0.8 0.7 0.17 0.05], ...
	'String','Show End Points', ...
	'Style','togglebutton');
  
ud.plotsToggle = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'Callback','epd showPlots', ...
	'ListboxTop',0, ...
	'Position',[0.8 0.83 0.17 0.05], ...
	'String','Show Plots', ...
	'Style','togglebutton');
  
ud.thresholdToggle = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'Callback','epd showThresholds', ...
	'ListboxTop',0, ...
	'Position',[0.8 0.77 0.17 0.05], ...
	'String','Show Thresholds', ...
	'Style','togglebutton');
  
ud.playCheck = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',[0.8 0.8 0.8], ...
	'ListboxTop',0, ...
	'Position',[0.8 0.64 0.18 0.04], ...
	'String','play on release', ...
	'Style','checkbox', ...
	'Value',1);
  
ud.Instructions = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',[0.8 0.8 0.8], ...
	'ListboxTop',0, ...
	'Position',[0.08 0.95 0.66 0.04], ...
	'String','Move the red cursors and estimate the word endpoints', ...
	'Style','text');

set(gcf,'UserData',ud);
