Free Books

Time Plots: myplot.m

Figure J.1: Compatibility matlab function for plotting a real-valued function--Octave version.

 
function myplot(x, y, sym, ttl, xlab, ylab, grd, lgnd)
% MYPLOT - Generic plot - compatibility wrapper for plot()
%          Octave version.  See below for Matlab version.
%          In Octave, title and axis labels must be issued
%          BEFORE the plot() command.

  if nargin<8, lgnd=''; end
  if nargin<7, grd=1; end
  if nargin<6, ylab=''; end
  if nargin<5, xlab=''; end
  if nargin<4, ttl=''; end
  if nargin<3, sym='*k'; end
  if nargin<2, y=x; x=0:length(y)-1; end

  title(ttl);
  ylabel(ylab);
  xlabel(xlab);
  if grd, grid('on'); else grid('off'); end
  plot(x,y,sym);
  legend(lgnd);

Figure J.2: Compatibility matlab function for plotting a real-valued function--Matlab version.

 
function myplot(x, y, sym, ttl, xlab, ylab, grd, lgnd)
% MYPLOT - Generic plot - compatibility wrapper for plot()
%          Matlab version. Title and axis labels must be
%          placed AFTER the plot() command.

  if nargin<8, lgnd=''; end
  if nargin<7, grd=1; end
  if nargin<6, ylab=''; end
  if nargin<5, xlab=''; end
  if nargin<4, ttl=''; end
  if nargin<3, sym='*k'; end
  if nargin<2, y=x; x=0:length(y)-1; end

  plot(x,y,sym);
  title(ttl);
  ylabel(ylab);
  xlabel(xlab);
  if grd, grid('on'); end
  legend(lgnd);


Next Section:
Frequency Plots: freqplot.m
Previous Section:
Filter Design by Minimizing the L2 Equation-Error Norm