function ep_plot(ep, c, Date1, Date2, LineColor) % EP_PLOT - Creates graph of ep data % % Use as: ep_plot(ep, c) % ep_plot(ep,c,LineType) % or ep_plot(ep, c, Date1, Date2, LineType) % Inputs: ep = Eqpac mooring number(1 or 2) % c = Column Number or Vector of Column numbers % Date1 = String representation of starting date (e.g. '01 jan 1998') % Date2 = String representation of ending date (e.g. '01 jan 1998') % LineColor = string color or 1x3 Vector of color values % Brian Schlining % 12 Apr 1999 % 15 Apr 1999; Modified to handle multiple columns warning off ep_ini; % Load the header of each column of data (ColumnS) and the units (UnitS) i = strcmp(ColumnS,'Decimal_Year'); x = ep_cmpl; % Read the data files in epX directories on tsunami numCols = length(c); %======================================= % Get the dates, Correct for Y2K issues %======================================= sdn = x(ep).dat(:,i) + 1900; %y2k = find(sdn >= 85 & sdn <= 99.9999); %sdn(y2k) = sdn(y2k) + 1900; %y2k = find(sdn >= 0 & sdn < 85); %sdn(y2k) = sdn(y2k) + 2000; sdn = dy2date(sdn); % Get Dates %========================================================= % Refine the approximate dates to make them more accurate %========================================================= [Year Month Day Hour Minute Second] = datevec(sdn); i = strcmp(ColumnS,'Time'); Hour = x(ep).dat(:,i); Hour(find(Hour == 1200)) = 12/24; Hour(find(Hour == 1230)) = 12.5/24; Day = round(Day) + Hour; % Correct the day to the local time sdn = datenum(Year, Month, Day); %================= % Check arguments %================= if nargin < 3 Date1 = min(sdn); Date2 = max(sdn); LineColor = 'k'; elseif nargin == 3 LineColor = Date1; Date1 = min(sdn); Date2 = max(sdn); elseif nargin == 4 Date1 = datenum(Date1); Date2 = datenum(Date2); LineColor = 'k'; end %===================================================== % Make sure that color matrix is same size as numCols %===================================================== [rl cl] = size(LineColor); if isstr(LineColor) & (cl > rl) LineColor = LineColor'; end if numCols > 1 & rl ==1 & cl == 1 LineColor = repmat(LineColor,numCols,1); end GOOD = find(sdn >= Date1 & sdn <= Date2); % Find Points within the Date Limits sdn = sdn(GOOD); m = 0; hl = []; for n = 1:numCols y = x(ep).dat(GOOD,c(n)); GOOD2 = find(~isnan(y)); y = y(GOOD2); sdn2 = sdn(GOOD2); if any(~isnan(y)) m = m + 1; hl(m) = plot(sdn2, y,'-'); set(hl(m),'Color',LineColor(n,:)) hold on hp = plot(sdn2, y,'.'); set(hp,'Color',LineColor(n,:)) end end xlabel('Date') if numCols == 1 ylabel(UnitsS(c)); title(ColumnS(c)); else legendS = [char(ColumnS(c)) char(UnitsS(c))]; if ~isempty(hl) legend(hl,legendS,0) end end if m hold off datetick('x',6); set(gca,'XLim',[Date1 Date2]) end setfontsize(7)