Sign in

username:

password:



Not a member?

Search Online Books



Search tips

Free Online Books

Sponsor

Evaluate multicore with Texas Instruments:
Low-cost evaluation module & free software development kit available NOW.

Chapters

See Also

Embedded SystemsFPGAElectronics
Chapter Contents:

Search Introduction to Digital Filters

  

Book Index | Global Index


Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?

  

Frequency Plots: freqplot.m

Figure J.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 J.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);


Previous: Time Plots: myplot.m
Next: Saving Plots to Disk: saveplot.m

Order a Hardcopy of Introduction to Digital Filters


About the Author: Julius Orion Smith III
Julius Smith's background is in electrical engineering (BS Rice 1975, PhD Stanford 1983). He is presently Professor of Music and Associate Professor (by courtesy) of Electrical Engineering at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), teaching courses and pursuing research related to signal processing applied to music and audio systems. See http://ccrma.stanford.edu/~jos/ for details.


Comments


No comments yet for this page


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )