Frequency Plots: freqplot.m Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search


Frequency Plots: freqplot.m

Figure H.3: Compatibility matlab function for plotting a real-valued function versus frequency--Octave version.

 
function freqplot(fdata, ydata, symbol, ttl, xlab, ylab)
% FREQPLOT - Plot a function of frequency:
%
%   freqplot(fdata[,ydata[,symbol[,title[,xlab[,ylab]]]]])
%
%   This version is most compatible with Octave.
%   In Matlab, the title and axis labels may be lost.
%   For Matlab compatibility, move the plot() command 
%   before title() and axis label commands.

  if nargin<6, ylab=''; end
  if nargin<5, xlab='Frequency'; end
  if nargin<4, ttl=''; end
  if nargin<3, symbol=''; end
  if nargin<2, ydata=fdata; fdata=0:length(ydata)-1; end

  if ttl, title(ttl); end
  if length(ylab)>0, ylabel(ylab); end
  if length(xlab)>0, xlabel(xlab); end
  grid('on');
  plot(fdata,ydata,symbol);

Figure H.4: Compatibility matlab function for plotting a real-valued function--Matlab version.

 
function freqplot(fdata, ydata, symbol, ttl, xlab, ylab)
% FREQPLOT - Plot a function of time, Matlab version.

  if nargin<6, ylab=''; end
  if nargin<5, xlab='Frequency (Hz)'; end
  if nargin<4, ttl=''; end
  if nargin<3, symbol=''; end
  if nargin<2, fdata=0:length(ydata)-1; end

  plot(fdata,ydata,symbol); grid;
  if ttl, title(ttl); end
  if ylab, ylabel(ylab); end
  xlabel(xlab);


Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

[How to cite this work] [Order a printed hardcopy]

``Introduction to Digital Filters with Audio Applications'', by Julius O. Smith III, (August 2006 Edition).
Copyright © 2007-02-02 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA  [Automatic-links disclaimer]